Idiom exclusion is really so important
Idiom exclusion is really so important
Posted Nov 14, 2024 16:13 UTC (Thu) by anton (subscriber, #25547)In reply to: Idiom exclusion is really so important by magfr
Parent article: Progress on toolchain security features
I would expect both to end up checking the flag result of x+y.Looking at <2024Sep6.152642@mips.complang.tuwien.ac.at>, gcc-10 generates the "naïve" code (on AMD64 9 bytes for "b<b=1" and 14 bytes for "b==LONG_MIN"), while gcc-12 generates the longer code from both idioms. Neither checks the flag result. You have to explicitly use __builtin_sub_overflow(b,1,&c) to get that, and then both versions generate a 6-byte sequence using add instead of the 5-byte sequence using dec. Whatever goes on in the minds of the gcc maintainers, there seem to be things on their agenda that are more important than generating short and fast code.
