On 4/16/2026 5:26 PM, Elias Rosberg wrote:
This patch allows Zcmp push and pop instructions in functions where
shrink-wrap-separate is not actually applied, leading to code size
reductions. The previous heuristic was overly blunt, disabling Zcmp for
any function where shrink-wrap-separate was enabled, without checking if
the optimization was utilized for that specific frame.

gcc/
        * config/riscv/riscv.cc (riscv_avoid_multi_push): Check if
        shrink-wrap-separate was actually used for the current
        function.

gcc/testsuite/
        * gcc.target/riscv/pr112478.c: Update scan-assembler patterns.
        * gcc.target/riscv/zcmp_shrink_wrap_separate.c: Likewise.
        * gcc.target/riscv/zcmp_no_shrink_wrap.c: New test.
        * gcc.target/riscv/zcmp_shrink_wrap.c: New test.
        * gcc.target/riscv/zcmp_shrink_wrap_sep.c: New test.

2026-04-17  Elias Rosberg  <[email protected]>
---
Hello,

I am a student researcher and this is my first GCC patch.
I identified a missed optimization where Zcmp cm.push/cm.pop
instructions were being suppressed at -O2 due to an overly blunt
check for shrink-wrap-separate.
Certainly possible.


It has passed the full C-torture execute/compile and target RISC-V
suite with no regressions. Quick testing on SQLite3 shows a ~1.7% reduction
in .text size for riscv32-unknown-elf at -O2.
That's a very nice improvement.


I do not have write access. So if this were to get approved,
I will need help with the commit
Yea, we can definitely help with that.  You would need to confirm that your patch is either covered by the DCO (developer certificate of origin) or assign your copyright interest in the change to the FSF.  DCO signoff is simplest.

The change itself looks fine.  So we really need either the DCO signoff or a copyright assignment.

https://gcc.gnu.org/dco.html

Jeff

Reply via email to