[llvm] [LV][EVL] Support cast instruction with EVL-vectorization (PR #108351)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 04:11:44 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());
----------------
LiqinWeng wrote:
IR Flags copy to Recipe, Recipe copy to EVLRecipe. IR Flags copy to EVLRecipe, Is there a problem?
https://github.com/llvm/llvm-project/pull/108351
More information about the llvm-commits
mailing list