https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113879
Bug ID: 113879
Summary: missed optimization - not exploiting known range of
integers
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: muecker at gwdg dot de
Target Milestone: ---
This is similar to PR105855 but without sanitizer.
In the following example the loop is not vectorized because the overflow check
(which is not needed) is not removed. It works when adding the first check
before the loop. But the information about j < INT_MAX can be derived directly
from j < i + 4.
void f(int i, float * restrict a, float * restrict b)
{
#if 0
if (INT_MAX - 4 < i)
__builtin_unreachable();
#endif
for (int j = i; j < i + 4; ) {
a[j] = b[j] + 1.;
#if 1
if (INT_MAX - 1 < j)
__builtin_trap();
#endif
j++;
}
}
https://godbolt.org/z/xnEbh5zfv