[Bug tree-optimization/112723] Missed optimization for invariants 'c+c' when c += -2147483648 and c is a global variable
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Nov 27 09:55:54 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112723
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's combine on RTL that is able to eliminate the addition/subtraction and
postreload the redundant shift. Nothing on GIMPLE optimizes
c.0_2 = (unsigned int) c_5(D);
_3 = c.0_2 + 2147483648;
c_8 = (int) _3;
_4 = c_8 * 2;
to
_4 = c_5(D) * 2;
note you need to write
c += -2147483647 - 1;
to avoid using 'long' (but I guess it's necessary to avoid undefined behavior).
So what's missing is a simplification pattern that ignores ops that only alter
bits that are dont-care in a later operation. That fits the backprop pass
best, not special simplification patterns.
More information about the Gcc-bugs
mailing list