https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115144
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Last reconfirmed| |2024-05-22 Status|UNCONFIRMED |ASSIGNED --- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Hans-Peter Nilsson from comment #7) > (In reply to Richard Biener from comment #6) [...] > > I do want to play with > > sinking to the start of the else {, but without doing any lifetime analysis > > I fear that's going to be worse in the average as the current location > > at least ensures we're close to the first use of the DEF we sink. > > Thank you in advance and for the look this far! I haven't looked closer at > what happens with later passes in main, but looking at the generated > assembly code, the "sinking" of a division has the eventual effect of > increasing register pressure; see the previously attached dumps. Indeed, we have originally _38 = _36 / _37; _39 = _36 % _37; r2_78 = (signed char) _39; where both _36 and _37 die (but _39 and _38 are live for a lot longer). We sink the _38 def across <bb 28> [local count: 173045540]: # iftmp.10_49 = PHI <iftmp.10_79(27), _31(51)> if (_41 >= iftmp.10_49) goto <bb 42>; [0.00%] else goto <bb 29>; [100.00%] <bb 29> [local count: 173045540]: r1.13_43 = (unsigned char) _38; which the original profile check avoided. I'll note the above is a more sensible case where to avoid such sinking but I'll also note that sinking does not look at register pressure (or basically whether a sinking increases or decreases register pressure) at all and generally GIMPLE passes are not supposed to do this (it's also not an easy feat).