http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58742
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Richard Biener from comment #4) > The patch will fix the regression part, to be left to optimize is the > pointer offset association bits which should best be done in GIMPLE > reassoc which doesn't yet associate POINTER_PLUS_EXPR yet. It could > do that with "transparently" handling > > ptr p+ (offset + ...) > > as > > (sizetype) ptr + (offset + ...) > > and in the final chain, if ptr prevailed, associate it first and > re-instantiate the POINTER_PLUS_EXPR, otherwise keep the sizetype > result and convert it to the pointer type (sizetype arith has > wrapping overflow so you cannot simply take any pointer in the > addition chain as the base for a POINTER_PLUS_EXRP). Not that easy as 'ptr' and '(sizetype) ptr' are not trivially computed equal by reassoc (it relies on CSE and has no value-numbering on its own).