gcc/
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Apr 2005 13:34:57 +0000 (13:34 +0000)
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Apr 2005 13:34:57 +0000 (13:34 +0000)
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.

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

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

index 5dc6889..3a5d50a 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 d773106..83d08f5 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 e8f52bb..014f195 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);
 }