OSDN Git Service

2009-10-05 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Oct 2009 13:18:09 +0000 (13:18 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Oct 2009 13:18:09 +0000 (13:18 +0000)
PR tree-optimization/23821
* tree-vrp.c (vrp_finalize): Do not perform copy propagation.
* tree-ssa-dom.c (cprop_operand): Do not propagate copies into
simple IV increments.

* gcc.dg/torture/pr23821.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152449 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr23821.c [new file with mode: 0644]
gcc/tree-ssa-dom.c
gcc/tree-vrp.c

index 4c0221d..a5460f3 100644 (file)
@@ -1,3 +1,10 @@
+2009-10-05  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/23821
+       * tree-vrp.c (vrp_finalize): Do not perform copy propagation.
+       * tree-ssa-dom.c (cprop_operand): Do not propagate copies into
+       simple IV increments.
+
 2009-10-05  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
         * config/arm/arm.c (arm_override_options): Really initialize
index 2631d12..ce023aa 100644 (file)
@@ -1,3 +1,8 @@
+2009-10-05  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/23821
+       * gcc.dg/torture/pr23821.c: New testcase.
+
 2009-10-05  Daniel Kraft  <d@domob.eu>
 
        PR fortran/41403
diff --git a/gcc/testsuite/gcc.dg/torture/pr23821.c b/gcc/testsuite/gcc.dg/torture/pr23821.c
new file mode 100644 (file)
index 0000000..7d42583
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* At -O1 DOM threads a jump in a non-optimal way which leads to
+   the bogus propagation.  */
+/* { dg-skip-if "" { *-*-* } { "-O1" } { "" } } */
+/* { dg-options "-fdump-tree-ivcanon-details" } */
+
+static int a[199];
+
+extern void abort (void);
+
+int
+main ()
+{
+  int i, x;
+  for (i = 0; i < 199; i++)
+    {
+      x = a[i];
+      if (x != i)
+       abort ();
+    }
+  return 0;
+}
+
+/* Verify that we do not propagate the equivalence x == i into the
+   induction variable increment.  */
+
+/* { dg-final { scan-tree-dump "Added canonical iv" "ivcanon" } } */
+/* { dg-final { cleanup-tree-dump "ivcanon" } } */
index 05a8d92..4bad3dd 100644 (file)
@@ -1998,6 +1998,12 @@ cprop_operand (gimple stmt, use_operand_p op_p)
       if (loop_depth_of_name (val) > loop_depth_of_name (op))
        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;
+
       /* Dump details.  */
       if (dump_file && (dump_flags & TDF_DETAILS))
        {
index 5780007..0cb227a 100644 (file)
@@ -7237,7 +7237,7 @@ vrp_finalize (void)
     }
 
   /* We may have ended with ranges that have exactly one value.  Those
-     values can be substituted as any other copy/const propagated
+     values can be substituted as any other const propagated
      value using substitute_and_fold.  */
   single_val_range = XCNEWVEC (prop_value_t, num_ssa_names);
 
@@ -7245,7 +7245,8 @@ vrp_finalize (void)
   for (i = 0; i < num_ssa_names; i++)
     if (vr_value[i]
        && vr_value[i]->type == VR_RANGE
-       && vr_value[i]->min == vr_value[i]->max)
+       && vr_value[i]->min == vr_value[i]->max
+       && is_gimple_min_invariant (vr_value[i]->min))
       {
        single_val_range[i].value = vr_value[i]->min;
        do_value_subst_p = true;