On 01/02/2018 06:19 AM, Richard Biener wrote: > On Wed, Dec 20, 2017 at 2:56 PM, Wilco Dijkstra <wilco.dijks...@arm.com> > wrote: >> This patch fixes PR83491 - if an SSA expression contains 2 identical float >> constants, the division reciprocal optimization will ICE. Fix this by >> explicitly >> checking for SSA_NAME in the tree code before walking the uses. Also fix >> several >> coding style issues pointed out by Jakub and make comments more readable. >> >> Bootstrap OK, OK for trunk? >> >> ChangeLog: >> 2017-12-20 Wilco Dijkstra <wdijk...@arm.com> >> >> gcc/ >> PR tree-optimization/83491 >> * tree-ssa-math-opts.c (execute_cse_reciprocals_1): Check for >> SSA_NAME >> before walking uses. Improve coding style and comments. >> >> gcc/testsuite/ >> PR tree-optimization/83491 >> * gcc.dg/pr83491.c: Add new test. >> -- >> >> diff --git a/gcc/testsuite/gcc.dg/pr83491.c b/gcc/testsuite/gcc.dg/pr83491.c >> new file mode 100644 >> index >> 0000000000000000000000000000000000000000..f23cc19c72f57ca8d34f05f28fee75fc2c13f33a >> --- /dev/null >> +++ b/gcc/testsuite/gcc.dg/pr83491.c >> @@ -0,0 +1,10 @@ >> +/* { dg-do compile } */ >> +/* { dg-options "-O1 -funsafe-math-optimizations" } */ >> + >> +float a; >> +float b; >> +void bar () >> +{ >> + a = __builtin_nanf (""); >> + b = __builtin_powf (a, 2.5F); >> +} >> diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c >> index >> 8db12f5e1cd5d227bd6c3780420e93cd3fe7b435..4e8f5e728d0c8ef5ac564d8c3c999d8a6ff15e7e >> 100644 >> --- a/gcc/tree-ssa-math-opts.c >> +++ b/gcc/tree-ssa-math-opts.c >> @@ -544,29 +544,32 @@ execute_cse_reciprocals_1 (gimple_stmt_iterator >> *def_gsi, tree def) >> int square_recip_count = 0; >> int sqrt_recip_count = 0; >> >> - gcc_assert (FLOAT_TYPE_P (TREE_TYPE (def)) && is_gimple_reg (def)); >> + gcc_assert (FLOAT_TYPE_P (TREE_TYPE (def)) && is_gimple_reg (def) >> + && TREE_CODE (def) == SSA_NAME); > > The is_gimple_reg () predicate test is now redundant. Agreed. I actually removed it in one of my recent bootstrap/regression test cycles. I'll commit the removal momentarily.
jeff