[PATCH] D80219: [VPlan] Use VPUser for VPWidenSelectRecipe operands (NFC).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 24 06:23:56 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG15224408f0d4: [VPlan] Use VPUser for VPWidenSelectRecipe operands (NFC). (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80219/new/

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();
@@ -4412,7 +4413,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
@@ -4420,12 +4423,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);
@@ -7134,7 +7137,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);
@@ -7429,7 +7433,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.265922.patch
Type: text/x-patch
Size: 3670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200524/2000db48/attachment-0001.bin>


More information about the llvm-commits mailing list