On 12/06/13 13:33, Jakub Jelinek wrote:
Hi!
range->exp can in some cases be equal to op, as in the following testcase:
<unnamed-unsigned:1> _2;
int _3;
_Bool _4;
int a.0_5;
_Bool _7;
<bb 2>:
_2 = b.f;
_3 = (int) _2;
_4 = _3 > 0;
_7 = _2 | _4;
a.0_5 = (int) _7;
a = a.0_5;
return a.0_5;
op here is _2 (and other range's op is _4), the two range tests have been
successfully merged and the code chose to use the first one to be the one
that is kept. Normally the range test isn't a SSA_NAME itself, but say
comparison etc. and thus emitting the statements before the statement
is desirable, but in this case we can't emit the new statements before it,
as they use _2. Fixed thusly, bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk and 4.8 (for the latter the fix is tiny bit
different, therefore attached)?
I was going to ask how this was possible, but then I looked at the
testcase... Sigh.
2013-12-06 Jakub Jelinek <ja...@redhat.com>
PR tree-optimization/59388
* tree-ssa-reassoc.c (update_range_test): If op == range->exp,
gimplify tem after stmt rather than before it.
* gcc.c-torture/execute/pr59388.c: New test.
OK for the trunk. Branch maintainers have final say for the branches.
jeff