If the high and low 32 bits are the same, we try to use
(ADD X, (SLLI X, 32)) but that only works if bit 31 is clear since
the low 32 bits will be sign extended.
If we have Zba we can use add.uw to zero the sign extended bits.
Differential D159253
[RISCV] Teach MatInt to use (ADD_UW X, (SLLI X, 32)) to materialize some constants. craig.topper on Aug 31 2023, 12:12 AM. Authored by
Details If the high and low 32 bits are the same, we try to use If we have Zba we can use add.uw to zero the sign extended bits.
Diff Detail
Unit Tests Event TimelineComment Actions LGTM. Mostly for completeness sake, here's how I convinced myself this is correct.
A couple of thoughts off that.
Comment Actions I think sh32add.uw is equivalent to the PACK instruction from the old Zbp spec which took the lower 32 bits from two registers and concatenated them. Comment Actions Agreed. I wish we had that instruction, but unfortunately we don't.
Yeah. I swapped the llvm IR name and the instruction name. |