https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120427
--- Comment #11 from Harald van Dijk <harald at gigawatt dot nl> --- (In reply to H.J. Lu from comment #10) > (In reply to Harald van Dijk from comment #9) > > (In reply to H.J. Lu from comment #2) > > > We shouldn't transform "mov $-1,reg" to "push $-1; pop reg". > > > We should transform "mov $-1,reg" to "or $-1,reg" instead. > > > > Is that really an improvement? For 32-bit registers, sure, it's fine, but > > for 64-bit registers this increases code size, does it not? orq $-1, %rax is > > four bytes, when pushq $-1; popq %rax is only three. > > By default, GCC optimizes for performance. "mov $-1,reg" is write. Other > encodings are write after read and maybe more. If you want the smallest code > size, please use -Oz. It was -Oz I was asking about. Look at the generated code for long f() { return -1; } at https://godbolt.org/z/z3shahbYK, comparing GCC 15.1 (without your patch) to GCC trunk (with your patch). This function used to be 4 bytes at -Oz, it is now 5 bytes.