[llvm] [AMDGPU] Rematerialize scalar loads (PR #68778)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 07:56:23 PDT 2023


================
@@ -2434,6 +2445,105 @@ bool SIInstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
   return true;
 }
 
+void SIInstrInfo::reMaterialize(MachineBasicBlock &MBB,
+                                MachineBasicBlock::iterator I, Register DestReg,
+                                unsigned SubIdx, const MachineInstr &Orig,
+                                const TargetRegisterInfo &RI) const {
+
+  // Try shrinking the instruction to remat only the part needed for current
+  // context.
+  // TODO: Handle more cases.
+  unsigned Opcode = Orig.getOpcode();
+  switch (Opcode) {
+  case AMDGPU::S_LOAD_DWORDX16_IMM:
+  case AMDGPU::S_LOAD_DWORDX8_IMM: {
+    if (SubIdx != 0)
+      break;
+
+    if (I == MBB.end())
+      break;
----------------
jayfoad wrote:

Oh I see, you are assuming that I points to a user (perhaps the only user) of the result of Orig.

https://github.com/llvm/llvm-project/pull/68778


More information about the llvm-commits mailing list