[llvm] [VPlan] Add ExtractLane VPInst to extract across multiple parts. (PR #148817)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 05:59:22 PDT 2025
================
@@ -860,6 +860,31 @@ Value *VPInstruction::generate(VPTransformState &State) {
Res = Builder.CreateOr(Res, State.get(Op));
return Builder.CreateOrReduce(Res);
}
+ case VPInstruction::ExtractLane: {
+ Value *LaneToExtract = State.get(getOperand(0), true);
+ Type *IdxTy = State.TypeAnalysis.inferScalarType(getOperand(0));
+ Value *Res = nullptr;
+ Value *RuntimeVF = getRuntimeVF(State.Builder, IdxTy, State.VF);
+
+ for (unsigned Idx = 1; Idx != getNumOperands(); ++Idx) {
+ Value *VectorStart =
+ Builder.CreateMul(RuntimeVF, ConstantInt::get(IdxTy, Idx - 1));
+ Value *VectorIdx = Idx == 1
+ ? LaneToExtract
+ : Builder.CreateSub(LaneToExtract, VectorStart);
----------------
lukel97 wrote:
I thought we used a ConstantFolder in the VPTransformState IR builder? Does this not get folded away when Idx == 1?
https://github.com/llvm/llvm-project/pull/148817
More information about the llvm-commits
mailing list