[llvm] [RISCV][GISEL] Legalize G_VSCALE (PR #85967)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 10:02:02 PDT 2024


================
@@ -2980,6 +2994,19 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
     Observer.changedInstr(MI);
     return Legalized;
   }
+  case TargetOpcode::G_VSCALE: {
+    MachineOperand &SrcMO = MI.getOperand(1);
+    LLVMContext &Ctx = MIRBuilder.getMF().getFunction().getContext();
+    const APInt &SrcVal = SrcMO.getCImm()->getValue();
+    // The CImm is always a signed value
+    const APInt &Val = SrcVal.sext(WideTy.getSizeInBits());
----------------
topperc wrote:

Nit, this can be `APInt Val =`. The sext creates a new APInt, so you're taking a reference to a temporary object.

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


More information about the llvm-commits mailing list