re PR tree-optimization/62217 (DOM confuses complete unrolling which in turn causes...
authorRichard Biener <rguenther@suse.de>
Wed, 18 Feb 2015 09:48:57 +0000 (09:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 18 Feb 2015 09:48:57 +0000 (09:48 +0000)
2015-02-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/62217
* tree-ssa-dom.c (cprop_operand): Avoid propagating copies
into BIVs.

* gcc.dg/tree-ssa/cunroll-11.c: New testcase.

From-SVN: r220785

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c [new file with mode: 0644]
gcc/tree-ssa-dom.c

index 2b06a25c6e6f4d464671fbf22f9d009a6e004cfb..6ede45769ad268bd25f0d3dae32d4bec4a96535b 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62217
+       * tree-ssa-dom.c (cprop_operand): Avoid propagating copies
+       into BIVs.
+
 2015-02-18  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/65081
index b277f57054e9a148e2639c3a19c8560ed0ca2177..0a1a328c7f0a15bf8ff2eebeb3d5c533d98605bf 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62217
+       * gcc.dg/tree-ssa/cunroll-11.c: New testcase.
+
 2015-02-18  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/65081
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c
new file mode 100644 (file)
index 0000000..a26cb22
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds -fdump-tree-cunroll-details" } */
+
+typedef struct { unsigned data; } s1;
+s1 g_x[4];
+
+extern void foo (s1 *x1, s1 *x2, int a, int b)
+{
+  int i;
+  for(i = 0; i < a; i++)
+    if(i == b)
+      g_x[i] = *x1;
+    else
+      g_x[i] = *x2;
+}
+
+/* { dg-final { scan-tree-dump "Loop 1 iterates at most 3 times" "cunroll" } } */
+/* { dg-final { cleanup-tree-dump "cunroll" } } */
index 9f0b2a5eadd37b455441bb4a73e08f74725720e0..096e4712675d0b9af66287a6e4edd19a33998cb3 100644 (file)
@@ -2291,11 +2291,16 @@ cprop_operand (gimple stmt, use_operand_p op_p)
       if (!may_propagate_copy (op, val))
        return;
 
-      /* Do not propagate copies into simple IV increment statements.
-         See PR23821 for how this can disturb IV analysis.  */
-      if (TREE_CODE (val) != INTEGER_CST
-         && simple_iv_increment_p (stmt))
-       return;
+      /* Do not propagate copies into BIVs.
+         See PR23821 and PR62217 for how this can disturb IV and
+        number of iteration analysis.  */
+      if (TREE_CODE (val) != INTEGER_CST)
+       {
+         gimple def = SSA_NAME_DEF_STMT (op);
+         if (gimple_code (def) == GIMPLE_PHI
+             && gimple_bb (def)->loop_father->header == gimple_bb (def))
+           return;
+       }
 
       /* Dump details.  */
       if (dump_file && (dump_flags & TDF_DETAILS))