[PATCH] D80219: [VPlan] Use VPUser for VPWidenSelectRecipe operands (NFC).
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 19 09:17:08 PDT 2020
fhahn created this revision.
fhahn added reviewers: Ayal, gilr, rengolin.
Herald added subscribers: vkmr, psnobl, rogfer01, rkruppe, bollu, hiraditya.
Herald added a project: LLVM.
VPWidenSelectRecipe already contains a VPUser, but it is not used. This
patch updates the code related to VPWidenSelectRecipe to use VPUser for
its operands.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80219
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -823,15 +823,17 @@
/// Hold the select to be widened.
SelectInst &Ingredient;
- /// Is the condition of the select loop invariant?
- bool InvariantCond;
-
/// Hold VPValues for the operands of the select.
VPUser User;
+ /// Is the condition of the select loop invariant?
+ bool InvariantCond;
+
public:
- VPWidenSelectRecipe(SelectInst &I, bool InvariantCond)
- : VPRecipeBase(VPWidenSelectSC), Ingredient(I),
+ template <typename IterT>
+ VPWidenSelectRecipe(SelectInst &I, iterator_range<IterT> Operands,
+ bool InvariantCond)
+ : VPRecipeBase(VPWidenSelectSC), Ingredient(I), User(Operands),
InvariantCond(InvariantCond) {}
~VPWidenSelectRecipe() override = default;
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -415,7 +415,8 @@
VPTransformState &State);
/// Widen a single select instruction within the innermost loop.
- void widenSelectInstruction(SelectInst &I, bool InvariantCond);
+ void widenSelectInstruction(SelectInst &I, VPUser &Operands,
+ bool InvariantCond, VPTransformState &State);
/// Fix the vectorized code, taking care of header phi's, live-outs, and more.
void fixVectorizedLoop();
@@ -4417,7 +4418,9 @@
}
void InnerLoopVectorizer::widenSelectInstruction(SelectInst &I,
- bool InvariantCond) {
+ VPUser &Operands,
+ bool InvariantCond,
+ VPTransformState &State) {
setDebugLocFromInst(Builder, &I);
// The condition can be loop invariant but still defined inside the
@@ -4425,12 +4428,12 @@
// We have to take the 'vectorized' value and pick the first lane.
// Instcombine will make this a no-op.
- auto *ScalarCond = getOrCreateScalarValue(I.getOperand(0), {0, 0});
+ auto *ScalarCond = State.get(Operands.getOperand(0), {0, 0});
for (unsigned Part = 0; Part < UF; ++Part) {
- Value *Cond = getOrCreateVectorValue(I.getOperand(0), Part);
- Value *Op0 = getOrCreateVectorValue(I.getOperand(1), Part);
- Value *Op1 = getOrCreateVectorValue(I.getOperand(2), Part);
+ Value *Cond = State.get(Operands.getOperand(0), Part);
+ Value *Op0 = State.get(Operands.getOperand(1), Part);
+ Value *Op1 = State.get(Operands.getOperand(2), Part);
Value *Sel =
Builder.CreateSelect(InvariantCond ? ScalarCond : Cond, Op0, Op1);
VectorLoopValueMap.setVectorValue(&I, Part, Sel);
@@ -7139,7 +7142,8 @@
if (auto *SI = dyn_cast<SelectInst>(Instr)) {
bool InvariantCond =
PSE.getSE()->isLoopInvariant(PSE.getSCEV(SI->getOperand(0)), OrigLoop);
- return new VPWidenSelectRecipe(*SI, InvariantCond);
+ return new VPWidenSelectRecipe(*SI, Plan->mapToVPValues(SI->operands()),
+ InvariantCond);
}
return tryToWiden(Instr, *Plan);
@@ -7434,7 +7438,7 @@
}
void VPWidenSelectRecipe::execute(VPTransformState &State) {
- State.ILV->widenSelectInstruction(Ingredient, InvariantCond);
+ State.ILV->widenSelectInstruction(Ingredient, User, InvariantCond, State);
}
void VPWidenRecipe::execute(VPTransformState &State) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80219.264939.patch
Type: text/x-patch
Size: 3670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200519/d93e7a77/attachment.bin>
More information about the llvm-commits
mailing list