https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112508
Roger Sayle <roger at nextmovesoftware dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |roger at nextmovesoftware dot com Last reconfirmed| |2024-02-15 --- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> --- The issue appears to be with (poor costing in) loop invariant store motion. Adding the command line option "-fno-move-loop-stores" reduces the .s file from 149 lines to 54 lines, and the size of main (as reported by objdump -d) from 317 bytes to 73 bytes. To confirm that this isn't specific to this (possibly pathological/obscure) test case, I ran the CSiBE benchmark on x86_64, comparing "-Os" to "-Os -fno-move-loop-stores", which shows a net saving of 1606 bytes with -fno-move-loop-stores. There are cases where -fno-move-loop-stores reduces code size (on x86_64, and I've not investigated other targets), so I guess it would be preferrable to use more accurate size costs instead of just disabling this sub-pass. Note that the bigger hammer, -fno-tree-loop-im, also avoids the code growth, but the more precise/specific -fno-move-loop-stores is sufficient.