diff mbox

[Bug,tree-optimization] Fix for PR71994

Message ID b36e94c5-637b-0cfa-9e7e-76192f175bda@linaro.org
State New
Headers show

Commit Message

Kugan Vivekanandarajah July 27, 2016, 12:10 a.m. UTC
Hi Jeff,

Thanks for your comments.

....

>>     * tree-ssa-reassoc.c (maybe_optimize_range_tests): Check type

>> compatibility.

> I'd kind of like to see some analysis of how we've got a bool here --

> ISTM it ought to have been converted it to the type of the LHS of the

> PHI when propagated.


You are right. The problem was with the order of checking tcc_compare 
and calling get_ops. We ended up calling get_ops where we should not.

Bootstrap and regression testing is ongoing. Is this OK for trunk if no 
regressions?

Thanks,
Kugan


gcc/testsuite/ChangeLog:

2016-07-27  Kugan Vivekanandarajah  <kuganv@linaro.org>

	* gcc.dg/torture/pr71994.c: New test.

gcc/ChangeLog:

2016-07-27  Kugan Vivekanandarajah  <kuganv@linaro.org>

	* tree-ssa-reassoc.c (maybe_optimize_range_tests): Check tcc_comparison
	 before calling get_ops.
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.dg/torture/pr71994.c b/gcc/testsuite/gcc.dg/torture/pr71994.c
index e69de29..8f5e92c 100644
--- a/gcc/testsuite/gcc.dg/torture/pr71994.c
+++ b/gcc/testsuite/gcc.dg/torture/pr71994.c
@@ -0,0 +1,14 @@ 
+/* PR tree-optimization/71994 */
+/* { dg-do compile } */
+int om, h6;
+
+void eo (void)
+{
+  const int tl = 1;
+  int ln;
+
+  h6 = (om + tl) > 0;
+  ln = om && (om & h6);
+  h6 = om;
+  om = ln < h6;
+}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 18cf978..8f2256f 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3520,10 +3520,10 @@  maybe_optimize_range_tests (gimple *stmt)
 	     push into ops the individual range test arguments
 	     of the bitwise or resp. and, recursively.  */
 	  if (TREE_CODE (rhs) == SSA_NAME
-	      && !get_ops (rhs, code, &ops,
-			loop_containing_stmt (stmt))
 	      && (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt))
 		  != tcc_comparison)
+	      && !get_ops (rhs, code, &ops,
+			loop_containing_stmt (stmt))
 	      && has_single_use (rhs))
 	    {
 	      /* Otherwise, push the _234 range test itself.  */