[llvm] [RISC-V][GISEL] Select G_BITCAST for scalable vectors (PR #101486)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 08:07:44 PDT 2024


================
@@ -785,6 +794,29 @@ void RISCVInstructionSelector::preISelLower(MachineInstr &MI,
     replacePtrWithInt(MI.getOperand(1), MIB, MRI);
     MI.setDesc(TII.get(TargetOpcode::G_AND));
     MRI.setType(DstReg, sXLen);
+    break;
+  }
+  case TargetOpcode::G_LOAD: {
+    Register DstReg = MI.getOperand(0).getReg();
+    const LLT DstTy = MRI.getType(DstReg);
+    if (!DstTy.isPointerVector() &&
+        "Destination register that's not a vector of pointers doesn't need to "
+        "go through preISelLower")
+      break;
+    replacePtrWithInt(MI.getOperand(0), MIB, MRI);
+    break;
+  }
+  case TargetOpcode::G_STORE: {
+    MachineOperand &SrcOp = MI.getOperand(0);
+    const LLT SrcTy = MRI.getType(SrcOp.getReg());
+    if (!SrcTy.isPointerVector() &&
+        "Source register that's not a vector of pointers doesn't need to go "
+        "through preISelLower")
+      break;
+    const LLT sXLen = LLT::scalar(STI.getXLen());
+    auto Copy = MIB.buildCopy(LLT::scalable_vector(SrcTy.getElementCount().getKnownMinValue(), sXLen), SrcOp);
----------------
michaelmaitland wrote:

nit: clang format

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


More information about the llvm-commits mailing list