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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 11:04:13 PDT 2024


================
@@ -2980,6 +3010,25 @@ 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();
+    unsigned ExtOpc = LI.getExtOpcodeForWideningConstant(
----------------
topperc wrote:

This is not consistent with SelectionDAG. The vscale constant is always a signed value.

```
SDValue DAGTypeLegalizer::PromoteIntRes_VSCALE(SDNode *N) {
  EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));

  const APInt &MulImm = N->getConstantOperandAPInt(0);
  return DAG.getVScale(SDLoc(N), VT, MulImm.sext(VT.getSizeInBits()));
}
```

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


More information about the llvm-commits mailing list