This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/78726] [5/6/7 Regression] Incorrect unsigned arithmetic optimization
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 08 Dec 2016 10:27:37 +0000
- Subject: [Bug middle-end/78726] [5/6/7 Regression] Incorrect unsigned arithmetic optimization
- Auto-submitted: auto-generated
- References: <bug-78726-4@http.gcc.gnu.org/bugzilla/>
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.