OSDN Git Service

2007-08-03 Andrew Pinski <andrew_pinski@playstation.sony.com>
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Aug 2007 13:08:29 +0000 (13:08 +0000)
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Aug 2007 13:08:29 +0000 (13:08 +0000)
    Diego Novillo  <dnovillo@google.com>

PR 31521
* tree-vrp.c (simplify_div_or_mod_using_ranges): Also simplify
if the range includes 0.

2007-08-03  Diego Novillo  <dnovillo@google.com>

PR 31521
* gcc.dg/tree-ssa/pr31521.c: New test.

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

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

index 04ff2e8..01a8d15 100644 (file)
@@ -1,3 +1,10 @@
+2007-08-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+           Diego Novillo  <dnovillo@google.com>
+
+       PR 31521
+       * tree-vrp.c (simplify_div_or_mod_using_ranges): Also simplify
+       if the range includes 0.
+
 2007-08-03  Ben Elliston  <bje@au.ibm.com>
 
        * config/spu/spu.md (dftsv, dftsv_celledp): Attach the appropriate
index ac0b329..0952f03 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-03  Diego Novillo  <dnovillo@google.com>
+
+       PR 31521
+       * gcc.dg/tree-ssa/pr31521.c: New test.
+
 2007-08-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/32770
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr31521.c b/gcc/testsuite/gcc.dg/tree-ssa/pr31521.c
new file mode 100644 (file)
index 0000000..4f54cc0
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+void fail(void) __attribute__((noreturn));
+int bar(int);
+
+int foo(int x) {
+  int i;
+  int s = 0;
+
+  if (x <= 0) fail();
+  for (i = 0; i < x; ++i) {
+    /* This division by 4 should be replaced with >> 2.  */
+    s += bar(i/4);
+  }
+  return s;
+}
+
+/* { dg-final { scan-tree-dump-times " = i_.* >> 2" 1 "vrp1" } } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
index fb31b9a..11e955f 100644 (file)
@@ -5541,7 +5541,7 @@ simplify_div_or_mod_using_ranges (tree stmt, tree rhs, enum tree_code rhs_code)
     {
       bool sop = false;
 
-      val = compare_range_with_value (GT_EXPR, vr, integer_zero_node, &sop);
+      val = compare_range_with_value (GE_EXPR, vr, integer_zero_node, &sop);
 
       if (val
          && sop