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.

Reply via email to