On Tue, Jul 26, 2016 at 5:13 AM, kugan <kugan.vivekanandara...@linaro.org> 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?
Ugh, this is undocumented spaghetti code I am not familiar with. I can't see if it is safe to truncate a constant here so I'd feel safer to just punt instead. Richard. > 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. >