[llvm] [VPlan] Add ExtractLane VPInst to extract across multiple parts. (PR #148817)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 23 05:17:00 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);
----------------
fhahn wrote:
InstSimplifyFolder can't be used, the IR is in an invalid/incomplete state which can cause incorrect folding (.e.g blocks are unreachable, phis not fully formed)
https://github.com/llvm/llvm-project/pull/148817
More information about the llvm-commits
mailing list