[Bug target/126454] [16/17 Regression] RISCV: cm.popretz pass deletes "li a0,0" and gives wrong return value

wren6991 at gmail dot com via Gcc-bugs <[email protected]> Sun, 02 Aug 2026 23:14:21 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126454

--- Comment #6 from Luke Wren <wren6991 at gmail dot com> ---
> The real fix is to use something different from reg_referenced_p which also handles implict clobbers of the call. (sometimes calls don't clobber a0).

I think the transformation would still be incorrect in that case because a0 is
also consumed by the call, even if not clobbered. If you absorb the `li a0`
into a `cm.popret` below the call then you're reordering it.