On 07/25/2016 09:13 PM, kugan wrote:
Hi,
For testcase in pr71994, type of bb conditional result and the type of
the PHI stmt are different (as om.0_1 is int and the first PHI argument
is _bool; PHI stmt uses a constant zero that comes from edge 2).
Therefore when we optimize final range test stmt, we end up setting
integer 1 for other PHI argument. This results in ICE.
<bb 2>:
om.0_1 = om;
_2 = om.0_1 >= 0;
int _3 = (int) _2;
if (om.0_1 != 0)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
int _4 = om.0_1 & _3;
_Bool _12 = _4 != 0;
<bb 4>:
# _Bool _13 = PHI <0(2), _12(3)>
IMHO, the fix should be that, we should check the type before replacing
the value (punt otherwise). Attached patch does that. Bootstrapped and
regression tested on x86_64-linux-gnu with no new regressions. Is this
OK for trunk?
Thanks,
Kugan
gcc/testsuite/ChangeLog:
2016-07-26 Kugan Vivekanandarajah <kug...@linaro.org>
* gcc.dg/torture/pr71994.c: New test.
gcc/ChangeLog:
2016-07-26 Kugan Vivekanandarajah <kug...@linaro.org>
* 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.
Jeff