https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110946
Bug ID: 110946 Summary: 3x perf regression with -Os on M1 Pro Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: dave.rodgman at arm dot com Target Milestone: --- Please see https://github.com/Mbed-TLS/mbedtls/pull/7784/commits/6cfd9b54ae0d06451c1a46a10e57fa099878bb03 for details. On M1 Pro, under -Os, we see a 3.1x performance regression for AES-XTS, which can be solved by forcing -O2 for two functions. For comparison, clang -Os gives around 5% perf regression (which is more in the ballpark that I'd expect). So it looks to me like gcc is getting something wrong when compiling these two functions with -Os. We measured a smaller but still significant difference (20-25%) on x86-64. Affects all versions of gcc that I was able to test with (9 .. 12).