[llvm] 2d5f025 - [LV] Extract utility for checking if VPValue is uniform [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 09:56:34 PDT 2022


Author: Philip Reames
Date: 2022-08-26T09:56:13-07:00
New Revision: 2d5f025779f497c54d90ddabbf2ef5290576dfd2

URL: https://github.com/llvm/llvm-project/commit/2d5f025779f497c54d90ddabbf2ef5290576dfd2
DIFF: https://github.com/llvm/llvm-project/commit/2d5f025779f497c54d90ddabbf2ef5290576dfd2.diff

LOG: [LV] Extract utility for checking if VPValue is uniform [nfc]

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index efff051401ef..68fab0f3d712 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2721,6 +2721,14 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
   }
 }
 
+/// Return true if this VPValue represents a computation which is
+/// uniform-per-part.
+static bool isUniform(VPValue *VPV) {
+  if (VPReplicateRecipe *OperandR = dyn_cast<VPReplicateRecipe>(VPV))
+    return OperandR->isUniform();
+  return false;
+}
+
 void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr,
                                                VPReplicateRecipe *RepRecipe,
                                                const VPIteration &Instance,
@@ -2758,8 +2766,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr,
   for (const auto &I : enumerate(RepRecipe->operands())) {
     auto InputInstance = Instance;
     VPValue *Operand = I.value();
-    VPReplicateRecipe *OperandR = dyn_cast<VPReplicateRecipe>(Operand);
-    if (OperandR && OperandR->isUniform())
+    if (isUniform(Operand))
       InputInstance.Lane = VPLane::getFirstLane();
     Cloned->setOperand(I.index(), State.get(Operand, InputInstance));
   }
@@ -9868,8 +9875,7 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part) {
     return ScalarValue;
   }
 
-  auto *RepR = dyn_cast<VPReplicateRecipe>(Def);
-  bool IsUniform = RepR && RepR->isUniform();
+  bool IsUniform = isUniform(Def);
 
   unsigned LastLane = IsUniform ? 0 : VF.getKnownMinValue() - 1;
   // Check if there is a scalar value for the selected lane.


        


More information about the llvm-commits mailing list