]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/71947 (x ^ y not folded to 0 if x == y by DOM)
authorRichard Biener <rguenther@suse.de>
Thu, 21 Jul 2016 13:00:32 +0000 (13:00 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Jul 2016 13:00:32 +0000 (13:00 +0000)
2016-07-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71947
* tree-vrp.c (extract_range_from_assert): Singleton symbolic
ranges have useful limit_vr information.

* gcc.dg/tree-ssa/vrp102.c: New testcase.

From-SVN: r238591

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

index 6c79b12354ecc044f613648c9fe03f8b46201561..39b3690852a2667c62de3b3940358cbd516366d4 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71947
+       * tree-vrp.c (extract_range_from_assert): Singleton symbolic
+       ranges have useful limit_vr information.
+
 2016-07-21  Richard Biener  <rguenther@suse.de>
 
        * function-tests.c (build_trivial_generic_function): Set
index 61b6fa900518f52ef97c352e53075b7ae05e6d0a..cb2f9e04103959162bcf3be866fecdf24afe24a9 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71947
+       * gcc.dg/tree-ssa/vrp102.c: New testcase.
+
 2016-07-21  Bin Cheng  <bin.cheng@arm.com>
 
        * gcc.dg/tree-ssa/scev-15.c: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp102.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp102.c
new file mode 100644 (file)
index 0000000..fb62e57
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp1" } */
+
+int f(int x, int y)
+{ 
+  int ret; 
+  if (x == y)
+    ret = x ^ y;
+  else
+    ret = 1;
+
+  return ret;
+} 
+
+/* We should have computed x ^ y as zero and propagated the result into the
+   PHI feeding the result.  */
+
+/* { dg-final { scan-tree-dump "ret_\[0-9\]+ = PHI <\[01\]\\\(\[0-9\]+\\\), \[01\]\\\(\[0-9\]+\\\)>" "vrp1" } } */
index b9ccb73ff798ee9b8d45c7b936d6c6c834f6b888..06364b70f3317acc4cc9c0510b003ea36ba4946c 100644 (file)
@@ -1513,10 +1513,13 @@ extract_range_from_assert (value_range *vr_p, tree expr)
   limit_vr = (TREE_CODE (limit) == SSA_NAME) ? get_value_range (limit) : NULL;
 
   /* LIMIT's range is only interesting if it has any useful information.  */
-  if (limit_vr
-      && (limit_vr->type == VR_UNDEFINED
-         || limit_vr->type == VR_VARYING
-         || symbolic_range_p (limit_vr)))
+  if (! limit_vr
+      || limit_vr->type == VR_UNDEFINED
+      || limit_vr->type == VR_VARYING
+      || (symbolic_range_p (limit_vr)
+         && ! (limit_vr->type == VR_RANGE
+               && (limit_vr->min == limit_vr->max
+                   || operand_equal_p (limit_vr->min, limit_vr->max, 0)))))
     limit_vr = NULL;
 
   /* Initially, the new range has the same set of equivalences of