From: Martin Liska Date: Mon, 25 Jul 2016 10:50:30 +0000 (+0200) Subject: Call get_ops just for SSA_NAMEs (PR tree-optimization/71987) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16b0596564668914c43e4dce6724af1e602664d4;p=gcc.git Call get_ops just for SSA_NAMEs (PR tree-optimization/71987) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 85dd5714540..a6755ab614c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-25 Martin Liska + + 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 PR gcov-profile/64874 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2c381514fb2..dcbc5c3e24e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-07-25 Martin Liska + + * gcc.dg/torture/pr71987.c: New test. + 2016-07-22 Steven G. Kargl 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 index 00000000000..87d59383af4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71987.c @@ -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; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index ece2d088044..18cf97806ae 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -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 ();