[llvm] [LV][EVL] Support icmp/fcmp instruction with EVL-vectorization (PR #108533)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 23 02:05:14 PDT 2024
================
@@ -1406,6 +1406,30 @@ InstructionCost VPWidenRecipe::computeCost(ElementCount VF,
void VPWidenEVLRecipe::execute(VPTransformState &State) {
unsigned Opcode = getOpcode();
// TODO: Support other opcodes
+ if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
+ Value *Op1 = State.get(getOperand(0), 0);
+ Value *Op2 = State.get(getOperand(1), 0);
+ auto &Ctx = State.Builder.getContext();
+ Value *Pred = MetadataAsValue::get(
+ Ctx, MDString::get(Ctx, CmpInst::getPredicateName(getPredicate())));
+
+ IRBuilderBase &BuilderIR = State.Builder;
+ VectorBuilder Builder(BuilderIR);
+
+ Value *Mask = BuilderIR.CreateVectorSplat(State.VF, BuilderIR.getTrue());
+ Builder.setMask(Mask).setEVL(State.get(getEVL(), /*NeedsScalar=*/true));
+ VectorType *RetType = VectorType::get(Type::getInt1Ty(Ctx), State.VF);
+ Value *VPInst = Builder.createVectorInstruction(Opcode, RetType,
+ {Op1, Op2, Pred}, "vp.op");
+ if (auto *VecOp = dyn_cast<CastInst>(VPInst))
----------------
Mel-Chen wrote:
Why createVectorInstruction may return CastInst if Opcode is ICmp/FCmp?
https://github.com/llvm/llvm-project/pull/108533
More information about the llvm-commits
mailing list