[Bug target/122948] sh: comparison is miscompiled
olegendo at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 18 11:42:11 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122948
--- Comment #4 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to celeriyacon from comment #3)
> The T flag calculation part of the "subc" insn in sh.md looks wrong:
>
> (gtu:SI (minus:SI (minus:SI (match_dup 1) (match_dup 2))
> (reg:SI T_REG))
> (match_dup 1)))]
>
>
> I think it should instead be something like:
>
> (gtu:SI (plus:DI (zero_extend:DI (match_dup:SI 2))
> (zero_extend:DI (reg:SI T_REG)))
> (zero_extend:DI (match_dup:SI 1))))]
Thanks for reporting this.
Have you tried to change the pattern to see if it fixes the problem?
I would be surprised if the T-bit calculation expression of "subc" (or of addc)
is actually used.
More information about the Gcc-bugs
mailing list