[Bug target/123181] Don't optimize to push 7; pop rcx on x86_64-pc-windows-*

blubban at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Dec 17 22:59:59 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123181

--- Comment #2 from Alfred Agrell <blubban at gmail dot com> ---
> I read the abi differently and it is about at function boundaries.

That certainly would be more intuitive, but the docs look clear enough to me:

> The stack pointer must remain 16-byte aligned in any region of code that isn't part of an epilog or prolog, except within leaf functions.

https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#unwindability

Though it certainly is rare for such subtle ABI contradictions to actually
cause trouble. Especially considering how rare -Oz is.

> There is no mention there cant be more than one prologue

Good point, I believe Microsoft calls that a shrinkwrapped function.

But prologues must be tagged as such in pdata/xdata, and that'd cost more bytes
than the optimization saves.


More information about the Gcc-bugs mailing list