Lovely. GCC 15 has a regression whereby -O2 now aggressively unrolls loops via vectorization, producing 4-5x the code size.
What is the point of having -O2 not include -funroll-loops (the main important difference vs -O3) if vectoriation is just going to do the exact same unrolling?? 🤬
Cross-posted from IRC:
What bothers me most about this is that there's an unspoken contract about -O levels that the compiler folks broke:
-Os means "I want this small af, I don't care if it's slow"
-O2 means "this is normal code that's not really a bottleneck, but I don't want it to be stupidly slow"
-O3 means "this is AAA gamer dude code, make it as fast as possible, I don't care what it costs"
And they went and make -O2 start doing -O3 stuff. 🤦
@dalias No love for -O1? :(
@dalias Er, I have a different understanding of the contract....
-Oz means "I want this small af, I don't care if it's slow"
-Os means "I care more about small than fast, but I do care about both. Also, this is normal code, don't be too fancy about it."
-O2 means "I care more about fast than small, but I do care about both. Also, this is normal code, don't be too fancy about it."
-O3 means "I care _much_ more about fast than small, and be as fancy as you need to in order to achieve this"
On the simple fixed-iteration-count loop I'm testing, GCC 14 and earlier and GCC 15 with -fno-tree-vectorize produce a tiny loop working on general purpose registers as intended.
GCC 15 without suppressing vectorization unrolls the entire thing in vector operations, and produces code that's the same number of instructions and larger code size than just -funroll-loops would do with general purpose registers.