https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104526
--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> --- (In reply to Jakub Jelinek from comment #2) > and evrp properly figured out those ranges, that 1 / int is [-1, 1] and > that 2 >> [-1, 1] is [1, 2]. > But since r12-6924 the IL is: > c.0_1 = c; > _2 = *c.0_1; > _11 = (unsigned int) _2; > _12 = _11 + 1; > _13 = _12 <= 2; > _3 = _12 <= 2 ? _2 : 0; > So, Andrew/Aldy, how hard would it be to improve ranger COND_EXPR handling, > so that it essentially does what we do for the PHI cases? I.e. from the > COND_EXPR condition, compute "assertion" if condition is true or if > condition is false, and use that on the COND_EXPR's second and third > argument. > So for the > _3 = _12 <= 2 ? _2 : 0; > comparison, for second argument the condition must be true which implies that > _2 must be there [-1, 1], while for the third argument the condition must be > false, but the argument is constant 0, so range is [0, 0], then just union > those 2 ranges. > > As this is a P1 regression, if we can fix it, would be nice to get it into > GCC 12. I'm having a look. The bits are all there. Most of gori is stmt oriented, but I may be able to invoke the components such that we evaluate the 2nd and 3rd arguemnts as if they were on true/false edges to improve the results..