Call get_ops just for SSA_NAMEs (PR tree-optimization/71987)
authorMartin Liska <mliska@suse.cz>
Mon, 25 Jul 2016 10:50:30 +0000 (12:50 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 25 Jul 2016 10:50:30 +0000 (10:50 +0000)
PR tree-optimization/71987
* tree-ssa-reassoc.c (maybe_optimize_range_tests): Call get_ops
just for SSA_NAMEs. Fix GNU coding style.
* gcc.dg/torture/pr71987.c: New test.

From-SVN: r238704

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr71987.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index 85dd57145401c6a90b6b2caccf8c124d117925f7..a6755ab614c51d71a8c9b5b527fa0c1b48463928 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-25  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/71987
+       * tree-ssa-reassoc.c (maybe_optimize_range_tests): Call get_ops
+       just for SSA_NAMEs. Fix GNU coding style.
+
 2016-07-25  Martin Liska  <mliska@suse.cz>
 
        PR gcov-profile/64874
index 2c381514fb2b990130acd5b99f64995bfc0723c2..dcbc5c3e24ec703be83ad813a1cf8b568a464b39 100644 (file)
@@ -1,3 +1,7 @@
+2016-07-25  Martin Liska  <mliska@suse.cz>
+
+       * gcc.dg/torture/pr71987.c: New test.
+
 2016-07-22  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/71935
diff --git a/gcc/testsuite/gcc.dg/torture/pr71987.c b/gcc/testsuite/gcc.dg/torture/pr71987.c
new file mode 100644 (file)
index 0000000..87d5938
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR tree-optimization/71987 */
+
+int a, b, *c, *d;
+
+short fn1 (int p1)
+{
+  return a ? p1 : a;
+}
+
+void fn2 ()
+{
+  int e, *f = &e;
+  b = fn1 (d != &e);
+  c = f;
+}
+
+int main ()
+{
+  fn2 ();
+  return 0;
+}
index ece2d0880448a324a0a41d00c2e72b5468ece1bb..18cf97806aec3c51193c0476b1309653842242fe 100644 (file)
@@ -3519,7 +3519,8 @@ maybe_optimize_range_tests (gimple *stmt)
             (or &, corresponding to 1/0 in the phi arguments,
             push into ops the individual range test arguments
             of the bitwise or resp. and, recursively.  */
-         if (!get_ops (rhs, code, &ops,
+         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)
@@ -3540,8 +3541,8 @@ maybe_optimize_range_tests (gimple *stmt)
          else if (is_gimple_assign (stmt)
                   && (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt))
                       == tcc_comparison)
-                  &&!get_ops (lhs, code, &ops,
-                              loop_containing_stmt (stmt))
+                  && !get_ops (lhs, code, &ops,
+                               loop_containing_stmt (stmt))
                   && has_single_use (lhs))
            {
              operand_entry *oe = operand_entry_pool.allocate ();