re PR tree-optimization/20657 ([tcb] VRP does not get rid of a redundant "if" statement.)
authorKazu Hirata <kazu@cs.umass.edu>
Thu, 14 Apr 2005 13:34:57 +0000 (13:34 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Thu, 14 Apr 2005 13:34:57 +0000 (13:34 +0000)
gcc/
PR tree-optimization/20657
* tree-vrp.c (extract_range_from_expr): Notice INTEGER_CST to
create an appropriate range from it.

testsuite/
PR tree-optimization/20657
* gcc.dg/tree-ssa/pr20657.c: New.

From-SVN: r98134

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

index 5dc6889c69eaad645de3c282a463378599b0ea7f..3a5d50a735c8df4bbeaed1730dffa90fa4990c2c 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-14  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/20657
+       * tree-vrp.c (extract_range_from_expr): Notice INTEGER_CST to
+       create an appropriate range from it.
+
 2005-04-14  Uros Bizjak  <uros@kss-loka.si>
 
        * reg-stack.c (subst_stack_regs_pat): Handle <UNSPEC_FIST_FLOOR> and
index d7731060aa80d3f8897c9d49aef33f3945edab43..83d08f52ed21cac46689c7cdc83d0cc3dffc650b 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-14  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/20657
+       * gcc.dg/tree-ssa/pr20657.c: New.
+
 2005-04-14  Uros Bizjak  <uros@kss-loka.si>
 
        * gcc.dg/builtins-53.c: Also check (int)trunc* and
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20657.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20657.c
new file mode 100644 (file)
index 0000000..ac89847
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR tree-optimization/20657
+   VRP did not pick up a conditional equivalence from the first "if"
+   statement, which was needed to eliminate the second "if" statement.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp-details" } */
+
+int
+foo (int a)
+{
+  if (a == 0)
+    if (a == 0)
+      return 1;
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Folding predicate" 1 "vrp"} } */
index e8f52bb72f40491d4c61f47a1de4db44924d5f04..014f1956926ea4457163b72eb449bb8376c1ee0a 100644 (file)
@@ -830,6 +830,8 @@ extract_range_from_expr (value_range *vr, tree expr)
     extract_range_from_unary_expr (vr, expr);
   else if (expr_computes_nonzero (expr))
     set_value_range_to_nonnull (vr, TREE_TYPE (expr));
+  else if (TREE_CODE (expr) == INTEGER_CST)
+    set_value_range (vr, VR_RANGE, expr, expr);
   else
     set_value_range (vr, VR_VARYING, NULL_TREE, NULL_TREE);
 }