Skip to content

Commit 66c35eb

Browse files
authored
[VPlan] Avoid branching around State.get (NFC) (#159042)
1 parent 0b1318f commit 66c35eb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,10 +1933,8 @@ void VPWidenSelectRecipe::execute(VPTransformState &State) {
19331933
// loop. This means that we can't just use the original 'cond' value.
19341934
// We have to take the 'vectorized' value and pick the first lane.
19351935
// Instcombine will make this a no-op.
1936-
auto *InvarCond =
1937-
isInvariantCond() ? State.get(getCond(), VPLane(0)) : nullptr;
1936+
Value *Cond = State.get(getCond(), isInvariantCond());
19381937

1939-
Value *Cond = InvarCond ? InvarCond : State.get(getCond());
19401938
Value *Op0 = State.get(getOperand(1));
19411939
Value *Op1 = State.get(getOperand(2));
19421940
Value *Sel = State.Builder.CreateSelect(Cond, Op0, Op1);
@@ -2495,18 +2493,14 @@ void VPWidenGEPRecipe::execute(VPTransformState &State) {
24952493
// produce a vector of pointers unless VF is scalar.
24962494
// The pointer operand of the new GEP. If it's loop-invariant, we
24972495
// won't broadcast it.
2498-
auto *Ptr = isPointerLoopInvariant() ? State.get(getOperand(0), VPLane(0))
2499-
: State.get(getOperand(0));
2496+
auto *Ptr = State.get(getOperand(0), isPointerLoopInvariant());
25002497

25012498
// Collect all the indices for the new GEP. If any index is
25022499
// loop-invariant, we won't broadcast it.
25032500
SmallVector<Value *, 4> Indices;
25042501
for (unsigned I = 1, E = getNumOperands(); I < E; I++) {
25052502
VPValue *Operand = getOperand(I);
2506-
if (isIndexLoopInvariant(I - 1))
2507-
Indices.push_back(State.get(Operand, VPLane(0)));
2508-
else
2509-
Indices.push_back(State.get(Operand));
2503+
Indices.push_back(State.get(Operand, isIndexLoopInvariant(I - 1)));
25102504
}
25112505

25122506
// Create the new GEP. Note that this GEP may be a scalar if VF == 1,

0 commit comments

Comments
 (0)