https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102032
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > Confirmed, one way of fixing this is to have a "lower" gimple where signed > integer overflow does not matter and then we can reassociate all we want. > There is a simple reassociatation on the RTL level but it does not catch > everything. Yes, that would fix it. There's some PR with a proof-of-concept patch. One of the issues with -fno-wrapv is that we cannot re-associate signed integer operations and thus 'a+b+c' and 'a+c+b' are not considered equal by value-numbering. With -frapv they are re-associated and are value-numbered the same, simplifying the code. Re-association could re-associate the signed integer ops by using unsigned computations but that's not implemented.