On 12/24/23 01:11, YunQiang Su wrote:
Yes. I also guess so.  Any new idea?
Well, I see multiple intertwined issues and I think MIPS has largely
mucked this up.

At a high level DI -> SI truncation is not a nop on MIPS64.  We must
explicitly sign extend the value from SI->DI to preserve the invariant
that SI mode objects are extended to DImode.  If we fail to do that,
then the SImode conditional branch patterns simply aren't going to work.


MIPS64 never claims DI -> SI is nop, instead it claims SI -> DI is nop.
And that just seems wrong, at least for truncation which implies the input precision must be larger than the output precision.

If you adjust the mips implementation of TARGET_TRULY_NOOP_TRUNCATION to return false when the input precision is smaller than the output precision, does that fix this problem?


And for MIPS64, it has only one type of branch. it works for both SI and DI.
Agreed, but the SImode variant is really just a DImode comparison that relies on the sign extending property of the MIPS architecture. I'm not 100% sure that's safe in the presence of bit manipulation instructions which do not preserve the sign extending property. We actually don't allow some bit manipulations on RV64 for a similar underlying reason.



Converting from 32 to 64 does be nop, IF the 32 is properly sign extended.
But that's not a *truncation*, that's an *extension*.

Jeff

Reply via email to