https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79721
Bug ID: 79721 Summary: Scalar evolution introduces signed overflow Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: krister.walfridsson at gmail dot com Target Milestone: --- The function int foo(int a, int b) { int sum = 0; for (int i = 0; i < 60000; i++) { sum += a + i * b; } return sum; } is transformed to int _11; int _12; int _13; int _16; [...] _16 = b_7(D) + a_8(D); _13 = _16 * 59999; _12 = b_7(D) * 1799910001; _11 = _12 + _13; sum_17 = _11 + a_8(D); return sum_17; by scalar evolution when compiled as "gcc -O3 -c bug.c". The original function could calculate foo(-30000, 2) without any signed integer overflow, but the transformed function will overflow in the multiplication _12.