[llvm] 9be8d90 - [VPlan] Add VPWidenSelectRecipe::getCond() (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 08:49:31 PST 2023


Author: Florian Hahn
Date: 2023-03-10T17:49:23+01:00
New Revision: 9be8d90e62a1f29f52fd5c7fc328cfe807a12c2e

URL: https://github.com/llvm/llvm-project/commit/9be8d90e62a1f29f52fd5c7fc328cfe807a12c2e
DIFF: https://github.com/llvm/llvm-project/commit/9be8d90e62a1f29f52fd5c7fc328cfe807a12c2e.diff

LOG: [VPlan] Add VPWidenSelectRecipe::getCond() (NFC).

Add helper to access condition, as suggested in D144489.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h
    llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 27c7e3945ddf..a20d4416457f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -980,8 +980,12 @@ struct VPWidenSelectRecipe : public VPRecipeBase, public VPValue {
              VPSlotTracker &SlotTracker) const override;
 #endif
 
+  VPValue *getCond() const {
+    return getOperand(0);
+  }
+
   bool isInvariantCond() const {
-    return getOperand(0)->isDefinedOutsideVectorRegions();
+    return getCond()->isDefinedOutsideVectorRegions();
   }
 };
 

diff  --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index d0a4cef33781..edc1e362d93d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -566,10 +566,10 @@ void VPWidenSelectRecipe::execute(VPTransformState &State) {
   // We have to take the 'vectorized' value and pick the first lane.
   // Instcombine will make this a no-op.
   auto *InvarCond =
-      isInvariantCond() ? State.get(getOperand(0), VPIteration(0, 0)) : nullptr;
+      isInvariantCond() ? State.get(getCond(), VPIteration(0, 0)) : nullptr;
 
   for (unsigned Part = 0; Part < State.UF; ++Part) {
-    Value *Cond = InvarCond ? InvarCond : State.get(getOperand(0), Part);
+    Value *Cond = InvarCond ? InvarCond : State.get(getCond(), Part);
     Value *Op0 = State.get(getOperand(1), Part);
     Value *Op1 = State.get(getOperand(2), Part);
     Value *Sel = State.Builder.CreateSelect(Cond, Op0, Op1);


        


More information about the llvm-commits mailing list