This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR87217
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Sep 2018 12:32:34 +0200 (CEST)
- Subject: [PATCH] Fix PR87217
This re-introduces the region boundary checking for the alias walk. It's
really also necessary for correctness, not only for compile-time.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2018-09-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/87217
* tree-ssa-sccvn.c (vuse_valueize): New.
(vn_reference_lookup_pieces): Use it.
(vn_reference_lookup): Likewise.
* gfortran.dg/pr87217.f: New testcase.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 264102)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -493,6 +493,25 @@ vuse_ssa_val (tree x)
return x;
}
+/* Similar to the above but used as callback for walk_non_aliases_vuses
+ and thus should stop at unvisited VUSE to not walk across region
+ boundaries. */
+
+static tree
+vuse_valueize (tree vuse)
+{
+ do
+ {
+ bool visited;
+ vuse = SSA_VAL (vuse, &visited);
+ if (!visited)
+ return NULL_TREE;
+ gcc_assert (vuse != VN_TOP);
+ }
+ while (SSA_NAME_IN_FREE_LIST (vuse));
+ return vuse;
+}
+
/* Return the vn_kind the expression computed by the stmt should be
associated with. */
@@ -2573,7 +2592,7 @@ vn_reference_lookup_pieces (tree vuse, a
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse,
vn_reference_lookup_2,
vn_reference_lookup_3,
- vuse_ssa_val, &vr1);
+ vuse_valueize, &vr1);
gcc_checking_assert (vr1.operands == shared_lookup_references);
}
@@ -2629,7 +2648,7 @@ vn_reference_lookup (tree op, tree vuse,
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse,
vn_reference_lookup_2,
vn_reference_lookup_3,
- vuse_ssa_val, &vr1);
+ vuse_valueize, &vr1);
gcc_checking_assert (vr1.operands == shared_lookup_references);
if (wvnresult)
{
Index: gcc/testsuite/gfortran.dg/pr87217.f
===================================================================
--- gcc/testsuite/gfortran.dg/pr87217.f (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87217.f (working copy)
@@ -0,0 +1,32 @@
+! { dg-do compile }
+! { dg-options "-O3" }
+ implicit real*8 (a-h,o-z)
+ common clop6(3),dps(6),aml6(6,6)
+ dimension y1(3)
+ dimension dclo(3)
+ dimension dx(3),dy(3)
+ save
+ do 80 ii=1,itco
+ y1(3)=dps(1)
+ do 40 l=1,3
+ dy(l)=clop6(l)-y1(l)
+ 40 continue
+ dczp=abs(dy(3))
+ if(dcx.le.c1m10.and.dcz.le.c1m10.and.dcxp.le.c1m10.and.dczp
+ + .le.c1m10.and.dcy.le.c1m10.and.dcyp.le.c1m10) goto 90
+ 80 continue
+ write(6) itco
+ ii=itco
+ 90 continue
+ if(ii.ne.itco) then
+ do 65 k=1,3
+ do 55 j=1,3
+ jj=2*j
+ kk=2*k
+ dclo(k)=aml6(kk-1,jj-1)*dx(j)+dclo(k)
+ dclo(k)=aml6(kk-1,jj)*dy(j)+dclo(k)
+ 55 continue
+ 65 continue
+ endif
+ end
+