[llvm] [VPlan] Handle FirstActiveLane when unrolling. (PR #145394)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 29 08:01:27 PDT 2025
================
@@ -856,9 +856,32 @@ Value *VPInstruction::generate(VPTransformState &State) {
return Builder.CreateOrReduce(Res);
}
case VPInstruction::FirstActiveLane: {
- Value *Mask = State.get(getOperand(0));
- return Builder.CreateCountTrailingZeroElems(Builder.getInt64Ty(), Mask,
- true, Name);
+ if (getNumOperands() == 1) {
+ Value *Mask = State.get(getOperand(0));
+ return Builder.CreateCountTrailingZeroElems(Builder.getInt64Ty(), Mask,
+ true, Name);
+ }
+ // If there are multiple operands, create a chain of selects to pick the
+ // first operand with an active lane and add the number of lanes of the
+ // preceding operands.
+ Value *RuntimeVF =
+ getRuntimeVF(State.Builder, State.Builder.getInt64Ty(), State.VF);
----------------
ayalz wrote:
```suggestion
Value *RuntimeVF = getRuntimeVF(Builder, Int64, State.VF);
```
Use `Builder` here, as above and below, rather than `State.Builder` (the former is set to the latter).
https://github.com/llvm/llvm-project/pull/145394
More information about the llvm-commits
mailing list