[Patch] Drop constant overflow flag in adjust_range_with_scev when possible
authorJiong Wang <jiwang@gcc.gnu.org>
Mon, 23 Nov 2015 12:14:05 +0000 (12:14 +0000)
committerJiong Wang <jiwang@gcc.gnu.org>
Mon, 23 Nov 2015 12:14:05 +0000 (12:14 +0000)
2015-11-23  Richard Biener  <rguenth@gcc.gnu.com>
            Jiong Wang  <jiong.wang@arm.com>

gcc/
  PR tree-optimization/68317
  PR tree-optimization/68326
  * tree-vrp.c (adjust_range_with_scev): Call drop_tree_overflow if the
  final min and max are not infinity.

gcc/testsuite/
  * gcc.dg/pr68317.c: New testcase.

From-SVN: r230754

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

index 530cf7810f9750c58f616833f17ad864ca08ad73..b1d0918ced97b4b308e3e35929e612f21cc4e439 100644 (file)
@@ -1,3 +1,11 @@
+2015-11-23  Richard Biener  <rguenth@gcc.gnu.org>
+           Jiong Wang  <jiong.wang@arm.com>
+
+       PR tree-optimization/68317
+       PR tree-optimization/68326
+       * tree-vrp.c (adjust_range_with_scev): Call drop_tree_overflow if the
+       final min and max are not infinity.
+
 2015-11-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
            Richard Biener  <rguenther@suse.de>
 
index 142347de801812cccfa97bd7e3b5692c4cb369cc..1c60e503b99273cc0c697951b09909d51a1a2955 100644 (file)
@@ -1,3 +1,10 @@
+2015-11-23  Richard Biener  <rguenther@suse.de>
+           Jiong Wang  <jiong.wang@arm.com>
+
+       PR tree-optimization/68317
+       PR tree-optimization/68326
+       * gcc.dg/pr68317.c: New testcase.
+
 2015-11-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
 
        PR tree-optimization/68327
diff --git a/gcc/testsuite/gcc.dg/pr68317.c b/gcc/testsuite/gcc.dg/pr68317.c
new file mode 100644 (file)
index 0000000..7b56563
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void bar (int);
+
+void
+foo ()
+{
+ int index = 0;
+
+ for (index; index <= 10; index--)
+   /* Result of the following multiply will overflow
+      when converted to signed int.  */
+   bar ((0xcafe + index) * 0xdead);
+}
index f2c948c2be1bceff9a8b44c33e062dfbe031ac4e..70011908acbf9adcaeb563661e66d00c88352c40 100644 (file)
@@ -4323,6 +4323,17 @@ adjust_range_with_scev (value_range *vr, struct loop *loop,
          && is_positive_overflow_infinity (max)))
     return;
 
+  /* Even for valid range info, sometimes overflow flag will leak in.
+     As GIMPLE IL should have no constants with TREE_OVERFLOW set, we
+     drop them except for +-overflow_infinity which still need special
+     handling in vrp pass.  */
+  if (TREE_OVERFLOW_P (min)
+      && ! is_negative_overflow_infinity (min))
+    min = drop_tree_overflow (min);
+  if (TREE_OVERFLOW_P (max)
+      && ! is_positive_overflow_infinity (max))
+    max = drop_tree_overflow (max);
+
   set_value_range (vr, VR_RANGE, min, max, vr->equiv);
 }