[Bug middle-end/78726] [5/6/7 Regression] Incorrect unsigned arithmetic optimization

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 8 10:27:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78726

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Most likely one of the endless reassoc bugs not properly updating or
invalidating range information.  Before reassoc1 we have:
  # RANGE [4294967040, 4294967295]
  a_11 = (unsigned int) _3;
  c.1_4 = c;
  # RANGE [0, 255] NONZERO 255
  _5 = (unsigned int) c.1_4;
  # RANGE ~[1, 4294902015]
  _6 = _5 * a_11;
  # RANGE ~[1, 4278320895]
  _7 = _5 * _6;
which looks correct, a_11 is int [-256, 1] converted to unsigned int, and c is
unsigned char.
But reassoc1 turns this into:
  # RANGE [4294967040, 4294967295]
  a_11 = (unsigned int) _3;
  c.1_4 = c;
  # RANGE [0, 255] NONZERO 255
  _5 = (unsigned int) c.1_4;
  # RANGE ~[1, 4278320895]
  _7 = _5 * _5;
  _13 = _7 + 1023094746;
  _14 = _13 * a_11;
It should have reused the SSA_NAME (_7) for something different, _5 * _5 has a
range of [0, 65025] and could have been used in debug stmts later on.


More information about the Gcc-bugs mailing list