From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122856 invoked by alias); 18 Apr 2016 13:10:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 122826 invoked by uid 89); 18 Apr 2016 13:10:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 spammy=pta, for_each_bb_fn, FOR_EACH_BB_FN, bitmap_set_bit X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 18 Apr 2016 13:10:28 +0000 Received: by mail-wm0-f42.google.com with SMTP id a140so119343286wma.0 for ; Mon, 18 Apr 2016 06:10:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=Vh7/lpBvCVOeUsNOEhL03rHZKgIP7V+A59cbtuZn7vI=; b=bIT0U4VtmYae80nMnQuP7J6WHZy3sWgbNZFL0lnVrX5LiOSBn9VLO+MV1vUHMEnI16 ut9dF81KCwUogXwisrXcTW4fWn0dxtPlQ8tksubdYc+RNeAN045WEKgi3QV879AiT45P outemhmRBZ9X6zYPXt8/uTzv6vMshO7JVx5eCBC96r2E3icoAl7xASe/u+bAiMNKNafY hLxMw4IZ/6FN+MnvrIgFIl/za78o7d9KFbotjudCg8hcpWvvUxe0Qg+fjwm5ju1Y1K4k TrEimoIRE04BDrjmchqsDQrIvype8saYdNdwjppnDPQi+ugvIzsXWrPquu/8/0/fRoXP Y0Vg== X-Gm-Message-State: AOPr4FX7Jb5/8xml1m6nM/NZ0ufaSQr7TJX4bNS5BUWy6KnyQX+YJPlXIW/i51KlDWrVCWtv/kHkTGg0cAsGCQ== MIME-Version: 1.0 X-Received: by 10.194.134.170 with SMTP id pl10mr34396262wjb.88.1460985025422; Mon, 18 Apr 2016 06:10:25 -0700 (PDT) Received: by 10.194.51.104 with HTTP; Mon, 18 Apr 2016 06:10:25 -0700 (PDT) In-Reply-To: References: Date: Mon, 18 Apr 2016 13:10:00 -0000 Message-ID: Subject: Re: [PATCH] Improve PTA restrict handling for non-restrict pointers From: Richard Biener To: GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00843.txt.bz2 On Mon, Feb 15, 2016 at 11:16 AM, Richard Biener wrote: > > Currently we only disambiguate restrict based accesses against pointer > based accesses that end up using a default def. The following removes > this restriction allowing disambiguation against any pointer based > access where PTA computed that the pointer cannot point to one of the > restrict tags we used to assign bases != 0 to. > > This results in extra disambigations (all non-restrict pointer IV > uses were not handled previously), see the added vectorizer testcase. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for GCC 7. Re-bootstrapped / tested and committed as r235147. Richard. > Richard. > > 2016-02-12 Richard Biener > > PR tree-optimization/43434 > * tree-ssa-structalias.c (struct vls_data): New. > (visit_loadstore): Handle all pointer-based accesses. > (compute_dependence_clique): Compute a bitmap of restrict tags > assigned bases and pass it to visit_loadstore. > > * gcc.dg/vect/pr43434.c: New testcase. > * c-c++-common/goacc/kernels-alias-3.c: Adjust. > * c-c++-common/goacc/kernels-alias-4.c: Likewise. > * c-c++-common/goacc/kernels-alias-5.c: Likewise. > * c-c++-common/goacc/kernels-alias-6.c: Likewise. > * c-c++-common/goacc/kernels-alias-7.c: Likewise. > * c-c++-common/goacc/kernels-alias-8.c: Likewise. > * gcc.dg/gomp/pr68640.c: Likewise. > > Index: gcc/tree-ssa-structalias.c > =================================================================== > *** gcc/tree-ssa-structalias.c (revision 233369) > --- gcc/tree-ssa-structalias.c (working copy) > *************** delete_points_to_sets (void) > *** 7162,7174 **** > obstack_free (&final_solutions_obstack, NULL); > } > > /* Mark "other" loads and stores as belonging to CLIQUE and with > base zero. */ > > static bool > ! visit_loadstore (gimple *, tree base, tree ref, void *clique_) > { > ! unsigned short clique = (uintptr_t)clique_; > if (TREE_CODE (base) == MEM_REF > || TREE_CODE (base) == TARGET_MEM_REF) > { > --- 7162,7181 ---- > obstack_free (&final_solutions_obstack, NULL); > } > > + struct vls_data > + { > + unsigned short clique; > + bitmap rvars; > + }; > + > /* Mark "other" loads and stores as belonging to CLIQUE and with > base zero. */ > > static bool > ! visit_loadstore (gimple *, tree base, tree ref, void *data) > { > ! unsigned short clique = ((vls_data *) data)->clique; > ! bitmap rvars = ((vls_data *) data)->rvars; > if (TREE_CODE (base) == MEM_REF > || TREE_CODE (base) == TARGET_MEM_REF) > { > *************** visit_loadstore (gimple *, tree base, tr > *** 7176,7188 **** > if (TREE_CODE (ptr) == SSA_NAME > && ! SSA_NAME_IS_DEFAULT_DEF (ptr)) > { > ! /* ??? We need to make sure 'ptr' doesn't include any of > the restrict tags we added bases for in its points-to set. */ > ! return false; > } > > - /* For now let decls through. */ > - > /* Do not overwrite existing cliques (that includes clique, base > pairs we just set). */ > if (MR_DEPENDENCE_CLIQUE (base) == 0) > --- 7183,7199 ---- > if (TREE_CODE (ptr) == SSA_NAME > && ! SSA_NAME_IS_DEFAULT_DEF (ptr)) > { > ! /* We need to make sure 'ptr' doesn't include any of > the restrict tags we added bases for in its points-to set. */ > ! varinfo_t vi = lookup_vi_for_tree (ptr); > ! if (! vi) > ! return false; > ! > ! vi = get_varinfo (find (vi->id)); > ! if (bitmap_intersect_p (rvars, vi->solution)) > ! return false; > } > > /* Do not overwrite existing cliques (that includes clique, base > pairs we just set). */ > if (MR_DEPENDENCE_CLIQUE (base) == 0) > *************** compute_dependence_clique (void) > *** 7255,7260 **** > --- 7266,7272 ---- > { > unsigned short clique = 0; > unsigned short last_ruid = 0; > + bitmap rvars = BITMAP_ALLOC (NULL); > for (unsigned i = 0; i < num_ssa_names; ++i) > { > tree ptr = ssa_name (i); > *************** compute_dependence_clique (void) > *** 7310,7347 **** > /* Now look at possible dereferences of ptr. */ > imm_use_iterator ui; > gimple *use_stmt; > FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr) > { > /* ??? Calls and asms. */ > if (!gimple_assign_single_p (use_stmt)) > continue; > ! maybe_set_dependence_info (gimple_assign_lhs (use_stmt), ptr, > ! clique, restrict_var, last_ruid); > ! maybe_set_dependence_info (gimple_assign_rhs1 (use_stmt), ptr, > ! clique, restrict_var, last_ruid); > } > } > } > > ! if (clique == 0) > ! return; > > ! /* Assign the BASE id zero to all accesses not based on a restrict > ! pointer. That way they get disabiguated against restrict > ! accesses but not against each other. */ > ! /* ??? For restricts derived from globals (thus not incoming > ! parameters) we can't restrict scoping properly thus the following > ! is too aggressive there. For now we have excluded those globals from > ! getting into the MR_DEPENDENCE machinery. */ > ! basic_block bb; > ! FOR_EACH_BB_FN (bb, cfun) > ! for (gimple_stmt_iterator gsi = gsi_start_bb (bb); > ! !gsi_end_p (gsi); gsi_next (&gsi)) > ! { > ! gimple *stmt = gsi_stmt (gsi); > ! walk_stmt_load_store_ops (stmt, (void *)(uintptr_t)clique, > ! visit_loadstore, visit_loadstore); > ! } > } > > /* Compute points-to information for every SSA_NAME pointer in the > --- 7322,7367 ---- > /* Now look at possible dereferences of ptr. */ > imm_use_iterator ui; > gimple *use_stmt; > + bool used = false; > FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr) > { > /* ??? Calls and asms. */ > if (!gimple_assign_single_p (use_stmt)) > continue; > ! used |= maybe_set_dependence_info (gimple_assign_lhs (use_stmt), > ! ptr, clique, restrict_var, > ! last_ruid); > ! used |= maybe_set_dependence_info (gimple_assign_rhs1 (use_stmt), > ! ptr, clique, restrict_var, > ! last_ruid); > } > + if (used) > + bitmap_set_bit (rvars, restrict_var->id); > } > } > > ! if (clique != 0) > ! { > ! /* Assign the BASE id zero to all accesses not based on a restrict > ! pointer. That way they get disabiguated against restrict > ! accesses but not against each other. */ > ! /* ??? For restricts derived from globals (thus not incoming > ! parameters) we can't restrict scoping properly thus the following > ! is too aggressive there. For now we have excluded those globals from > ! getting into the MR_DEPENDENCE machinery. */ > ! vls_data data = { clique, rvars }; > ! basic_block bb; > ! FOR_EACH_BB_FN (bb, cfun) > ! for (gimple_stmt_iterator gsi = gsi_start_bb (bb); > ! !gsi_end_p (gsi); gsi_next (&gsi)) > ! { > ! gimple *stmt = gsi_stmt (gsi); > ! walk_stmt_load_store_ops (stmt, &data, > ! visit_loadstore, visit_loadstore); > ! } > ! } > > ! BITMAP_FREE (rvars); > } > > /* Compute points-to information for every SSA_NAME pointer in the > Index: gcc/testsuite/gcc.dg/vect/pr43434.c > =================================================================== > *** gcc/testsuite/gcc.dg/vect/pr43434.c (revision 0) > --- gcc/testsuite/gcc.dg/vect/pr43434.c (working copy) > *************** > *** 0 **** > --- 1,27 ---- > + /* { dg-do compile } */ > + > + typedef short DCTELEM; > + typedef unsigned char uint8_t; > + > + void diff_pixels_c(DCTELEM *__restrict__ block, const uint8_t *s1, > + const uint8_t *s2, int stride) > + { > + int i; > + > + for(i=0;i<8;i++) > + { > + block[0] = s1[0] - s2[0]; > + block[1] = s1[1] - s2[1]; > + block[2] = s1[2] - s2[2]; > + block[3] = s1[3] - s2[3]; > + block[4] = s1[4] - s2[4]; > + block[5] = s1[5] - s2[5]; > + block[6] = s1[6] - s2[6]; > + block[7] = s1[7] - s2[7]; > + s1 += stride; > + s2 += stride; > + block += 8; > + } > + } > + > + /* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_int && { vect_unpack && vect_hw_misalign } } } } } */ > Index: gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c > =================================================================== > --- gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c (revision 233418) > +++ gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c (working copy) > @@ -14,7 +14,8 @@ foo (void) > } > } > > -/* Only the omp_data_i related loads should be annotated with cliques. */ > +/* Only the omp_data_i related loads should be annotated with > + non-base 0 cliques. */ > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */ > > Index: gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c > =================================================================== > --- gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c (revision 233418) > +++ gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c (working copy) > @@ -16,7 +16,8 @@ foo (void) > } > } > > -/* Only the omp_data_i related loads should be annotated with cliques. */ > +/* Only the omp_data_i related loads should be annotated with > + non-base 0 cliques. */ > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */ > > Index: gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c > =================================================================== > --- gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c (revision 233418) > +++ gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c (working copy) > @@ -15,5 +15,5 @@ foo (int *a) > > /* Only the omp_data_i related loads should be annotated with cliques. */ > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 4 "ealias" } } */ > > Index: gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c > =================================================================== > --- gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c (revision 233418) > +++ gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c (working copy) > @@ -19,5 +19,5 @@ foo (void) > > /* Only the omp_data_i related loads should be annotated with cliques. */ > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */ > > Index: gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c > =================================================================== > --- gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c (revision 233418) > +++ gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c (working copy) > @@ -21,5 +21,5 @@ foo (void) > > /* Only the omp_data_i related loads should be annotated with cliques. */ > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */ > > Index: gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c > =================================================================== > --- gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c (revision 233418) > +++ gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c (working copy) > @@ -18,5 +18,5 @@ foo (int *a, size_t n) > > /* Only the omp_data_i related loads should be annotated with cliques. */ > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */ > > Index: gcc/testsuite/gcc.dg/gomp/pr68640.c > =================================================================== > --- gcc/testsuite/gcc.dg/gomp/pr68640.c (revision 233418) > +++ gcc/testsuite/gcc.dg/gomp/pr68640.c (working copy) > @@ -13,4 +13,4 @@ foo (int *__restrict__ ap) > } > > /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ > -/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ > +/* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 2 "ealias" } } */