re PR tree-optimization/21001 (VRP is weak when the tested variable in a COND_EXPR...
authorKazu Hirata <kazu@cs.umass.edu>
Mon, 18 Apr 2005 06:10:45 +0000 (06:10 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Mon, 18 Apr 2005 06:10:45 +0000 (06:10 +0000)
gcc/
PR tree-optimization/21001
* tree-optimize.c (init_tree_optimization_passes): Move the
first pass_forwprop immediately before pass_vrp.

testsuite/
PR tree-optimization/21001
* gcc.dg/tree-ssa/pr21001.c: New.

From-SVN: r98309

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr21001.c [new file with mode: 0644]
gcc/tree-optimize.c

index 64c39f9..8a70d69 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-18  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/21001
+       * tree-optimize.c (init_tree_optimization_passes): Move the
+       first pass_forwprop immediately before pass_vrp.
+
 2005-04-17  Ian Lance Taylor  <ian@airs.com>
 
        * c-common.def (SIZEOF_EXPR, ARROW_EXPR, ALIGNOF_EXPR): Remove.
index b683caf..b4e22d5 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-18  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/21001
+       * gcc.dg/tree-ssa/pr21001.c: New.
+
 2005-04-17  Thomas Koenig  <Thomas.Koenig@online.de>
 
        PR libfortran/21075
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c
new file mode 100644 (file)
index 0000000..c274cd3
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR tree-optimization/21001
+   VRP did not insert ASSERT_EXPRs when the variable tested in a
+   COND_EXPR is a single-use variable.  By propagating the definition
+   of the single-use variable into the COND_EXPR, we can get useful
+   range infomation out of the conditional.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp-details" } */
+
+int
+foo (int a)
+{
+  int b = a != 0;
+  if (b)
+    if (a != 0)
+      return 1;
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Folding predicate" 1 "vrp"} } */
index 4d172c2..2284a79 100644 (file)
@@ -356,9 +356,9 @@ init_tree_optimization_passes (void)
   NEXT_PASS (pass_dominator);
   NEXT_PASS (pass_copy_prop);
   NEXT_PASS (pass_dce);
+  NEXT_PASS (pass_forwprop);
   NEXT_PASS (pass_vrp);
   NEXT_PASS (pass_merge_phi);
-  NEXT_PASS (pass_forwprop);
   NEXT_PASS (pass_phiopt);
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_tail_recursion);