[llvm] [LV] Support binary and unary operations with EVL-vectorization (PR #93854)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 01:27:55 PDT 2024
================
@@ -1208,6 +1212,43 @@ InstructionCost VPWidenRecipe::computeCost(ElementCount VF,
}
}
+void VPWidenEVLRecipe::execute(VPTransformState &State) {
+ unsigned Opcode = getOpcode();
+ // TODO: Support other opcodes
+ if (!Instruction::isBinaryOp(Opcode) && !Instruction::isUnaryOp(Opcode))
+ llvm_unreachable("Unsupported opcode in VPWidenEVLRecipe::execute");
+
+ State.setDebugLocFrom(getDebugLoc());
+ assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
+ "explicit vector length.");
+ VPValue *Op0 = getOperand(0);
+
+ assert(State.get(Op0, 0)->getType()->isVectorTy() &&
+ "VPWidenEVLRecipe should not be used for scalars");
+
+ VPValue *EVL = getEVL();
+ Value *EVLArg = State.get(EVL, 0, /*NeedsScalar=*/true);
+ IRBuilderBase &BuilderIR = State.Builder;
+ VectorBuilder Builder(BuilderIR);
+ Value *Mask = BuilderIR.CreateVectorSplat(State.VF, BuilderIR.getTrue());
+
+ SmallVector<Value *, 4> Ops;
+ for (unsigned I = 0, E = getNumOperands() - 1; I < E; ++I) {
+ VPValue *VPOp = getOperand(I);
+ Ops.push_back(State.get(VPOp, 0));
+ }
+
+ Builder.setMask(Mask).setEVL(EVLArg);
+ Value *VPInst =
+ Builder.createVectorInstruction(Opcode, Ops[0]->getType(), Ops, "vp.op");
+ if (isa<FPMathOperator>(VPInst))
----------------
fhahn wrote:
IIUC only FMFs can be set here as other flags are not supported on calls. Would be good to document here
https://github.com/llvm/llvm-project/pull/93854
More information about the llvm-commits
mailing list