From patchwork Tue Dec 11 22:49:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 205332 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A21682C00A3 for ; Wed, 12 Dec 2012 09:56:14 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355871374; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=QOySnTj VuW/TEkaO72tJyLhdnk0=; b=Ofu5Ytgp5mpZrK/nArGrsgFlFeXHm2lcZtRIBBX ny7R09GdfP6FWMyM+njybsDo6f+KipmPO+5OLw640eXorHO4kEpZunUNfZxwRG2z GNFj8pQwRihEgl/RBKBPch9ZF1iIB+Y3r5wMLE4kX2GnfLcDRoIRY1vb70oM95b9 t0hI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=y2wrfzOlDH0MzbbKTje8ULS9uEQRjJqyzg6hQmUKeduXx+RJLNy4T0P479danZ 4Jn8vC2K5yGWTzlnPDb8WE/jx8Sm9t6kqi7SchdQwUUqNozFUua54HXsNJ80h8bT lJXei1L/6WEbt4TP6Gm37nfqkKzfrkUaRH1vMc4nf0UDg=; Received: (qmail 26941 invoked by alias); 11 Dec 2012 22:49:10 -0000 Received: (qmail 26932 invoked by uid 22791); 11 Dec 2012 22:49:09 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-ie0-f175.google.com (HELO mail-ie0-f175.google.com) (209.85.223.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 22:49:03 +0000 Received: by mail-ie0-f175.google.com with SMTP id qd14so4859ieb.20 for ; Tue, 11 Dec 2012 14:49:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-gm-message-state; bh=Y5wEE7iC9iVyqpg5SxF8OdRXpSj7Utm3d0pYNxJMsF0=; b=CJmVlPOv0bVk2bo844xjLLYjgZyUKp7Szm6PBjqUmsu4X8Sd0fSMWtVd3752J9HuV3 H5ZPK1iK61S5LLad3PkxD3MOpCERlgJheHNjHidktFKC0cr/XhmkUCk7v7fRRtwoSiyU pVdqhK9qgvy/PJUvOHqA+aQdEwzONdqf5bbixcM+SY2dq8FFDWH2+NtRA848I66LrrTu 4SNaaWIaeKQGckuZrNH1CyVw4aTlbCTqdrUog78tVb82hhLCTwccvHdyTaq1Ca5KmmXO mE031Uv6TarBHWY3kWyjhG0WzIQFdsD65IDS47OWzrJhQlXZiqUvCdZfUUPDmnYjTPw0 rgzQ== MIME-Version: 1.0 Received: by 10.43.83.1 with SMTP id ae1mr15663903icc.24.1355266142710; Tue, 11 Dec 2012 14:49:02 -0800 (PST) Received: by 10.231.199.18 with HTTP; Tue, 11 Dec 2012 14:49:02 -0800 (PST) Date: Tue, 11 Dec 2012 14:49:02 -0800 Message-ID: Subject: [cxx-conversion] Convert tree-vectorizer.h'_loop_vec_info::peeling_htab to hash_table From: Lawrence Crowl To: gcc-patches List X-Gm-Message-State: ALoCoQkeXwPhrOZw2TWd+t5sMqi6/UTb90kl2OJkxwA8hvy9zJDZ+iyBiq7LjltDPfexUj7YBTOriRiZ0OkIsPrOauaaD33t2oXpDg+p0rG7+YnxJrXRaja3JaskJudrlLm02Ffh4+LC9gNaLf0lfW2/fyQZ4N5hhpxJbEl8W5Qev706UhSNQ5o8B3zWuLq5mkyENuEH4qig X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Convert tree-vectorizer.h'_loop_vec_info::peeling_htab from htab_t to hash_table. * tree-vectorizer.h New struct peel_info_hasher. * tree-vect-loop.c Update dependent calls and types to match. * tree-vect-data-refs.c Fold vect_peeling_hash and vect_peeling_hash_eq into struct peel_info_hasher. Update dependent calls and types to match. Tested on x86_64. Okay for branch? Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h (revision 194381) +++ gcc/tree-vectorizer.h (working copy) @@ -192,6 +192,30 @@ typedef struct _vect_peel_extended_info stmt_vector_for_cost body_cost_vec; } *vect_peel_extended_info; + +/* Peeling hashtable helpers. */ + +struct peel_info_hasher : typed_free_remove <_vect_peel_info> +{ + typedef _vect_peel_info value_type; + typedef _vect_peel_info compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + +inline hashval_t +peel_info_hasher::hash (const value_type *peel_info) +{ + return (hashval_t) peel_info->npeel; +} + +inline bool +peel_info_hasher::equal (const value_type *a, const compare_type *b) +{ + return (a->npeel == b->npeel); +} + + /*-----------------------------------------------------------------*/ /* Info on vectorized loops. */ /*-----------------------------------------------------------------*/ @@ -276,7 +300,7 @@ typedef struct _loop_vec_info { vec reduction_chains; /* Hash table used to choose the best peeling option. */ - htab_t peeling_htab; + hash_table peeling_htab; /* Cost data used by the target cost model. */ void *target_cost_data; Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 194381) +++ gcc/tree-vect-loop.c (working copy) @@ -874,7 +874,6 @@ new_loop_vec_info (struct loop *loop) LOOP_VINFO_REDUCTION_CHAINS (res).create (10); LOOP_VINFO_SLP_INSTANCES (res).create (10); LOOP_VINFO_SLP_UNROLLING_FACTOR (res) = 1; - LOOP_VINFO_PEELING_HTAB (res) = NULL; LOOP_VINFO_TARGET_COST_DATA (res) = init_cost (loop); LOOP_VINFO_PEELING_FOR_GAPS (res) = false; LOOP_VINFO_OPERANDS_SWAPPED (res) = false; @@ -969,8 +968,8 @@ destroy_loop_vec_info (loop_vec_info loo LOOP_VINFO_REDUCTIONS (loop_vinfo).release (); LOOP_VINFO_REDUCTION_CHAINS (loop_vinfo).release (); - if (LOOP_VINFO_PEELING_HTAB (loop_vinfo)) - htab_delete (LOOP_VINFO_PEELING_HTAB (loop_vinfo)); + if (LOOP_VINFO_PEELING_HTAB (loop_vinfo).is_created ()) + LOOP_VINFO_PEELING_HTAB (loop_vinfo).dispose (); destroy_cost_data (LOOP_VINFO_TARGET_COST_DATA (loop_vinfo)); Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 194381) +++ gcc/Makefile.in (working copy) @@ -967,7 +967,8 @@ GIMPLE_STREAMER_H = gimple-streamer.h $( TREE_STREAMER_H = tree-streamer.h $(TREE_H) $(LTO_STREAMER_H) \ $(STREAMER_HOOKS_H) STREAMER_HOOKS_H = streamer-hooks.h $(TREE_H) -TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) $(TARGET_H) +TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) $(TARGET_H) \ + $(HASH_TABLE_H) IPA_PROP_H = ipa-prop.h $(TREE_H) $(VEC_H) $(CGRAPH_H) $(GIMPLE_H) alloc-pool.h IPA_INLINE_H = ipa-inline.h $(IPA_PROP_H) GSTAB_H = gstab.h stab.def Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c (revision 194381) +++ gcc/tree-vect-data-refs.c (working copy) @@ -1275,27 +1275,6 @@ vect_get_data_access_cost (struct data_r } -static hashval_t -vect_peeling_hash (const void *elem) -{ - const struct _vect_peel_info *peel_info; - - peel_info = (const struct _vect_peel_info *) elem; - return (hashval_t) peel_info->npeel; -} - - -static int -vect_peeling_hash_eq (const void *elem1, const void *elem2) -{ - const struct _vect_peel_info *a, *b; - - a = (const struct _vect_peel_info *) elem1; - b = (const struct _vect_peel_info *) elem2; - return (a->npeel == b->npeel); -} - - /* Insert DR into peeling hash table with NPEEL as key. */ static void @@ -1303,12 +1282,11 @@ vect_peeling_hash_insert (loop_vec_info int npeel) { struct _vect_peel_info elem, *slot; - void **new_slot; + _vect_peel_info **new_slot; bool supportable_dr_alignment = vect_supportable_dr_alignment (dr, true); elem.npeel = npeel; - slot = (vect_peel_info) htab_find (LOOP_VINFO_PEELING_HTAB (loop_vinfo), - &elem); + slot = LOOP_VINFO_PEELING_HTAB (loop_vinfo).find (&elem); if (slot) slot->count++; else @@ -1317,8 +1295,7 @@ vect_peeling_hash_insert (loop_vec_info slot->npeel = npeel; slot->dr = dr; slot->count = 1; - new_slot = htab_find_slot (LOOP_VINFO_PEELING_HTAB (loop_vinfo), slot, - INSERT); + new_slot = LOOP_VINFO_PEELING_HTAB (loop_vinfo).find_slot (slot, INSERT); *new_slot = slot; } @@ -1330,11 +1307,11 @@ vect_peeling_hash_insert (loop_vec_info /* Traverse peeling hash table to find peeling option that aligns maximum number of data accesses. */ -static int -vect_peeling_hash_get_most_frequent (void **slot, void *data) +int +vect_peeling_hash_get_most_frequent (_vect_peel_info **slot, + _vect_peel_extended_info *max) { - vect_peel_info elem = (vect_peel_info) *slot; - vect_peel_extended_info max = (vect_peel_extended_info) data; + vect_peel_info elem = *slot; if (elem->count > max->peel_info.count || (elem->count == max->peel_info.count @@ -1352,11 +1329,11 @@ vect_peeling_hash_get_most_frequent (voi /* Traverse peeling hash table and calculate cost for each peeling option. Find the one with the lowest cost. */ -static int -vect_peeling_hash_get_lowest_cost (void **slot, void *data) +int +vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot, + _vect_peel_extended_info *min) { - vect_peel_info elem = (vect_peel_info) *slot; - vect_peel_extended_info min = (vect_peel_extended_info) data; + vect_peel_info elem = *slot; int save_misalignment, dummy; unsigned int inside_cost = 0, outside_cost = 0, i; gimple stmt = DR_STMT (elem->dr); @@ -1436,14 +1413,16 @@ vect_peeling_hash_choose_best_peeling (l { res.inside_cost = INT_MAX; res.outside_cost = INT_MAX; - htab_traverse (LOOP_VINFO_PEELING_HTAB (loop_vinfo), - vect_peeling_hash_get_lowest_cost, &res); + LOOP_VINFO_PEELING_HTAB (loop_vinfo) + .traverse <_vect_peel_extended_info *, + vect_peeling_hash_get_lowest_cost> (&res); } else { res.peel_info.count = 0; - htab_traverse (LOOP_VINFO_PEELING_HTAB (loop_vinfo), - vect_peeling_hash_get_most_frequent, &res); + LOOP_VINFO_PEELING_HTAB (loop_vinfo) + .traverse <_vect_peel_extended_info *, + vect_peeling_hash_get_most_frequent> (&res); } *npeel = res.peel_info.npeel; @@ -1648,10 +1627,8 @@ vect_enhance_data_refs_alignment (loop_v size_zero_node) < 0; /* Save info about DR in the hash table. */ - if (!LOOP_VINFO_PEELING_HTAB (loop_vinfo)) - LOOP_VINFO_PEELING_HTAB (loop_vinfo) = - htab_create (1, vect_peeling_hash, - vect_peeling_hash_eq, free); + if (!LOOP_VINFO_PEELING_HTAB (loop_vinfo).is_created ()) + LOOP_VINFO_PEELING_HTAB (loop_vinfo).create (1); vectype = STMT_VINFO_VECTYPE (stmt_info); nelements = TYPE_VECTOR_SUBPARTS (vectype);