https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94541
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #10)
> (In reply to Andrew Pinski from comment #8)
> > (In reply to H.J. Lu from comment #7)
> > > After 284r.ira:
> >
> > That is fine according to the rules as long as TARGET_TRULY_NOOP_TRUNCATION
> > is true.
>
> We can't turn
>
> (insn 13 12 14 3 (set (reg:SI 4 si)
> (subreg:SI (reg/v:DI 85 [ b ]) 0)) "y.i":14:14 67 {*movsi_internal}
> (expr_list:REG_DEAD (reg/v:DI 85 [ b ])
> (nil)))
>
> into
>
>
> (insn 13 12 14 3 (set (reg:SI 4 si)
> (reg:SI 4 si [orig:85 b ] [85])) "y.i":14:14 67 {*movsi_internal}
> (expr_list:REG_DEAD (reg/v:DI 4 si [orig:85 b ] [85])
> (nil)))
>
> This is simple wrong.
How is that wrong? What register was 85 assigned to? 4?
Then is fully correct as TARGET_TRULY_NOOP_TRUNCATION is true for those sizes.
On MIPS, TARGET_TRULY_NOOP_TRUNCATION is false for SI/DI truncation.
You need TARGET_TRULY_NOOP_TRUNCATION to be false for those sizes and you get a
truncate RTL instead of the subreg. subreg means the upper bits of the
register are undefined.