[llvm] [AArch64][GlobalISel] Make G_DUP immediate 32-bits or larger (PR #96780)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 01:21:19 PDT 2024


================
@@ -420,6 +420,25 @@ void AArch64RegisterBankInfo::applyMappingImpl(
     MI.getOperand(2).setReg(Ext.getReg(0));
     return applyDefaultMapping(OpdMapper);
   }
+  case AArch64::G_DUP: {
+    // Extend smaller gpr to 32-bits
+    Builder.setInsertPt(*MI.getParent(), MI.getIterator());
+
+    Register ConstReg;
+    auto ConstMI = MRI.getVRegDef(MI.getOperand(1).getReg());
+    if (ConstMI->getOpcode() == TargetOpcode::G_CONSTANT) {
+      auto CstVal = ConstMI->getOperand(1).getCImm()->getValue();
+      ConstReg =
+          Builder.buildConstant(LLT::scalar(32), CstVal.sext(32)).getReg(0);
+      ConstMI->eraseFromParent();
+    } else {
+      ConstReg = Builder.buildAnyExt(LLT::scalar(32), MI.getOperand(1).getReg())
+                     .getReg(0);
+    }
----------------
chuongg3 wrote:

i32 and i64 constants are not changed, only constants that are smaller than 32-bits get extended

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


More information about the llvm-commits mailing list