[llvm] [LV][EVL] Support icmp/fcmp instruction with EVL-vectorization (PR #108533)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 13:03:17 PDT 2024
================
@@ -1353,6 +1353,34 @@ 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 *DataType = VectorType::get(Type::getInt1Ty(Ctx), State.VF);
+
+ Value *VPInst = Builder.createVectorInstruction(Opcode, DataType,
+ {Op1, Op2, Pred}, "vp.op");
+ // if (isa<FPMathOperator>(VPInst))
+ // setFlags(cast<Instruction>(VPInst));
+ if (VPInst) {
----------------
artagnon wrote:
Unnecessary check?
https://github.com/llvm/llvm-project/pull/108533
More information about the llvm-commits
mailing list