https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124528
Bug ID: 124528
Summary: New signed overflow introduced by sccp
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: kristerw at gcc dot gnu.org
Blocks: 118443
Target Milestone: ---
sccp introduces a new signed overflow when the function below is compiled for
x86_64 with -Os:
int baz (int n, int m)
{
return n == 0 ? 100 : (baz (n - 1, m) - m);
}
The optimized version calculates the result as:
int baz (int n, int m)
{
int add_acc_7;
int acc_tmp_9;
int _10;
unsigned int _11;
unsigned int _12;
unsigned int _13;
<bb 2> [local count: 118111600]:
_10 = -m_5(D);
_11 = (unsigned int) _10;
_12 = (unsigned int) n_3(D);
_13 = _11 * _12;
add_acc_7 = (int) _13;
acc_tmp_9 = add_acc_7 + 100;
return acc_tmp_9;
}
The original code did not overflow when called as
baz(0, 0x80000000);
but the optimized code overflows when calculating _10.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118443
[Bug 118443] [Meta bug] Bugs triggered by and blocking more smtgcc testing