This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/79721] New: Scalar evolution introduces signed overflow
- From: "krister.walfridsson at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 26 Feb 2017 23:38:17 +0000
- Subject: [Bug tree-optimization/79721] New: Scalar evolution introduces signed overflow
- Auto-submitted: auto-generated
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.