[llvm] [AArch64][GlobalISel] Make G_DUP immediate 32-bits or larger (PR #96780)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 02:02:18 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);
+ }
----------------
davemgreen wrote:
It might be good to add an assert that the type isn't larger than we expect
https://github.com/llvm/llvm-project/pull/96780
More information about the llvm-commits
mailing list