aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-03-30 07:15:39 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-03-30 07:15:39 +0000
commit28c024077899ff4bad1fbce2d38fa8b5709272ef (patch)
tree38df20abe28191bb91f3ec3d687054afe48af750
parente0aa80e05e24176051ef644856dd25784344308a (diff)
downloadgcc-28c024077899ff4bad1fbce2d38fa8b5709272ef.zip
gcc-28c024077899ff4bad1fbce2d38fa8b5709272ef.tar.gz
gcc-28c024077899ff4bad1fbce2d38fa8b5709272ef.tar.bz2
re PR tree-optimization/77498 (Performance drop after r239414 on spec2000/172mgrid)
2017-03-30 Richard Biener <rguenther@suse.de> PR tree-optimization/77498 * tree-ssa-pre.c (phi_translate_1): Do not allow simplifications to non-constants over backedges. * gfortran.dg/pr77498.f: New testcase. From-SVN: r246583
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr77498.f36
-rw-r--r--gcc/tree-ssa-pre.c18
4 files changed, 61 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 85b1c37..3333bfd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-03-30 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/77498
+ * tree-ssa-pre.c (phi_translate_1): Do not allow simplifications
+ to non-constants over backedges.
+
2017-03-29 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/80233
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d8e6f87..5d33ce7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-30 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/77498
+ * gfortran.dg/pr77498.f: New testcase.
+
2017-03-29 Marek Polacek <polacek@redhat.com>
PR c/79730
diff --git a/gcc/testsuite/gfortran.dg/pr77498.f b/gcc/testsuite/gfortran.dg/pr77498.f
new file mode 100644
index 0000000..f957b57
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr77498.f
@@ -0,0 +1,36 @@
+! { dg-do compile }
+! { dg-options "-O2 -ffast-math -fdump-tree-pre" }
+
+ subroutine foo(U,V,R,N,A)
+ integer N
+ real*8 U(N,N,N),V(N,N,N),R(N,N,N),A(0:3)
+ integer I3, I2, I1
+C
+ do I3=2,N-1
+ do I2=2,N-1
+ do I1=2,N-1
+ R(I1,I2,I3)=V(I1,I2,I3)
+ * -A(0)*( U(I1, I2, I3 ) )
+ * -A(1)*( U(I1-1,I2, I3 ) + U(I1+1,I2, I3 )
+ * + U(I1, I2-1,I3 ) + U(I1, I2+1,I3 )
+ * + U(I1, I2, I3-1) + U(I1, I2, I3+1) )
+ * -A(2)*( U(I1-1,I2-1,I3 ) + U(I1+1,I2-1,I3 )
+ * + U(I1-1,I2+1,I3 ) + U(I1+1,I2+1,I3 )
+ * + U(I1, I2-1,I3-1) + U(I1, I2+1,I3-1)
+ * + U(I1, I2-1,I3+1) + U(I1, I2+1,I3+1)
+ * + U(I1-1,I2, I3-1) + U(I1-1,I2, I3+1)
+ * + U(I1+1,I2, I3-1) + U(I1+1,I2, I3+1) )
+ * -A(3)*( U(I1-1,I2-1,I3-1) + U(I1+1,I2-1,I3-1)
+ * + U(I1-1,I2+1,I3-1) + U(I1+1,I2+1,I3-1)
+ * + U(I1-1,I2-1,I3+1) + U(I1+1,I2-1,I3+1)
+ * + U(I1-1,I2+1,I3+1) + U(I1+1,I2+1,I3+1) )
+ enddo
+ enddo
+ enddo
+ return
+ end
+
+! PRE shouldn't do predictive commonings job here (and in a bad way)
+! ??? It still does but not as bad as it could. Less prephitmps
+! would be better, pcom does it with 6.
+! { dg-final { scan-tree-dump-times "# prephitmp" 9 "pre" } }
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index ff59d53..c6aa587 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -1468,10 +1468,20 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
leader for it. */
if (constant->kind != CONSTANT)
{
- unsigned value_id = get_expr_value_id (constant);
- constant = find_leader_in_sets (value_id, set1, set2);
- if (constant)
- return constant;
+ /* Do not allow simplifications to non-constants over
+ backedges as this will likely result in a loop PHI node
+ to be inserted and increased register pressure.
+ See PR77498 - this avoids doing predcoms work in
+ a less efficient way. */
+ if (find_edge (pred, phiblock)->flags & EDGE_DFS_BACK)
+ ;
+ else
+ {
+ unsigned value_id = get_expr_value_id (constant);
+ constant = find_leader_in_sets (value_id, set1, set2);
+ if (constant)
+ return constant;
+ }
}
else
return constant;