[llvm] [LV][EVL] Support cast instruction with EVL-vectorization (PR #108351)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 00:23:24 PDT 2024


================
@@ -1381,6 +1384,34 @@ void VPWidenCastRecipe::execute(VPTransformState &State) {
   }
 }
 
+void VPWidenCastEVLRecipe::execute(VPTransformState &State) {
+  unsigned Opcode = getOpcode();
+  auto Inst = cast<CastInst>(getUnderlyingInstr());
+  State.setDebugLocFrom(getDebugLoc());
+  assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
+                          "explicit vector length.");
+
+  Value *SrcVal = State.get(getOperand(0), 0);
+  VectorType *DsType = VectorType::get(getResultType(), State.VF);
+
+  IRBuilderBase &BuilderIR = State.Builder;
+  VectorBuilder Builder(BuilderIR);
+  Value *Mask = BuilderIR.CreateVectorSplat(State.VF, BuilderIR.getTrue());
+  Builder.setMask(Mask).setEVL(State.get(getEVL(), 0, /*NeedsScalar=*/true));
+
+  Value *VPInst =
+      Builder.createVectorInstruction(Opcode, DsType, {SrcVal}, "vp.cast");
+
+  if (VPInst) {
+    if (auto *VecOp = dyn_cast<CastInst>(VPInst))
+      VecOp->copyIRFlags(getUnderlyingInstr());
----------------
arcbbb wrote:

since `VPWidenCastRecipe::execute` doesn't set ir flags, what flag do you expect to set here ?

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


More information about the llvm-commits mailing list