[Bug tree-optimization/53806] Missed optimization (a<=b)&&(a>=b) with trapping
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 1 07:28:55 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53806
--- Comment #6 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Drea Pinski from comment #4)
> (In reply to Drea Pinski from comment #3)
> > So this looks like this is optimized due to frange work.
> > That is dom and evrp change `a<=b` into `a==b` and then ifcombine/phiopt can
> > handle that.
>
> well not exactly because we don't combine then until reassociation because
> of:
>
> ```
> /* If we changed the conditions that cause a trap, we lose. */
> if ((ltrap || rtrap) != trap)
> return NULL_TREE;
> ```
>
> Which I think this should be if we had didn't have a trap, don't introduce a
> trap.
>
> So this should be:
> ```
> if (!ltrap && !rtrap && trap)
> return NULL_TREE;
> ```
>
> Let me try that; that will allow phiopt to optimize it without
> reassociation. (with the fix for PR 106164).
Yes it allows phiopt to do the otimization when dealing with `a>=b & a == b`.
And it fixes fold dealing with `a>=b && a<=b` but both ifcombine and phiopt
does not handle the case where the second one is trapping and the first is
trapping.
That will be handled seperately and I still have a few ideas on how to look at
fixing that.
More information about the Gcc-bugs
mailing list