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

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

--- Comment #7 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Luke Wren from comment #6)
> > 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.

Oh yes. I thought there is another function that used to get which registers
are used for calls. I dont remember what it is though.