https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92980
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Hongtao.liu from comment #3) > > ptrop ---> src1 + 18446744073709551612; > intop ---> j > > It seems on purpose??? Kinda. What needs to happen is a sign extend rather than a zero extend which is what this code is doing really in a weird way. Take (This is a modified testcase from PR4401 which was added in 2002 because of a C++ bug report and when the code was moved from being C specific to being C family specific): char *a; char b[] = "AAAA"; void foo (void) { unsigned int i, j; i = 2; j = 3; a[i + 1 - j] += i; } int main (void) { a = b; foo (); if (b[0] != 'A' + 2) __builtin_abort (); __builtin_exit (0); } --- CUT --- NOTE this code dates before the GCC code was moved into source control (1992). I suspect it has not changed because it is "working". Also note from that time period to now, there has been much more optimizations going on so this might be something which should change too. The comment says this: /* If what we are about to multiply by the size of the elements contains a constant term, apply distributive law and multiply that constant term separately. This helps produce common subexpressions. */ But that is not true any more. So I think this optimization can be removed as it is too early. Just double check the above testcase and the C++ testcase (g++.dg/opt/ptrintsum1.C) to make sure they still work and post that removal. This optimization is most likely causing other missed optimizations already too. So I would compile SPEC to see if there is any differences; my bet you might find some.