Bug 105855 - missed optimization - vectorization -fsanitize=signed-integer-overflow
Summary: missed optimization - vectorization -fsanitize=signed-integer-overflow
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 13.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2022-06-05 09:57 UTC by Martin Uecker
Modified: 2022-06-06 08:48 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Uecker 2022-06-05 09:57:17 UTC
It would be nice if -fsanitize=signed-integer-overflow
would impact optimization less, so it could be used
in production more often.


In the following example, using this flag prevents
vectorization:


void f(int i, float * restrict a, float * restrict b) 
{     
    for (int j = i; j < i + 4; ++j)
        a[j] = b[j] + 1.;
}


https://godbolt.org/z/raqdd794x
Comment 1 Andrew Pinski 2022-06-05 10:21:22 UTC
You could in theory version the loop for the no overflow case.
Now is the question becomes is it worth the cost of implementing it in the compiler. I doubt it.
Comment 2 Martin Uecker 2022-06-06 08:48:34 UTC
Clang seems to do a combined check before the loop without creating a new version.