https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67607
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> --- In general, for unsigned x, 1+(unsigned long)(x-1) can be simplified to x only if we know that x!=0, so we would need VRP information. Maybe this could be handled as part of the type-promotion work. VRP could tell that _21+1 can be computed in type unsigned int, and swap the operation and the conversion. Or it could tell that _19-1 can be computed in type unsigned long, it doesn't matter much which one it picks. The simplification -1+1 would then be trivial. Last idea would be to try and avoid generating so many +1 and -1 in the first place.