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.
Paths
| Differential D159253
[RISCV] Teach MatInt to use (ADD_UW X, (SLLI X, 32)) to materialize some constants. ClosedPublic Authored by craig.topper on Aug 31 2023, 12:12 AM.
Details Summary 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
Event TimelineThis revision is now accepted and ready to land.Aug 31 2023, 12:56 AM Comment 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. This revision was landed with ongoing or failed builds.Aug 31 2023, 8:25 PM Closed by commit rG319aba645f6a: [RISCV] Teach MatInt to use (ADD_UW X, (SLLI X, 32)) to materialize some… (authored by craig.topper). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 555243 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/imm.ll
|