[LV] Consistently use vputils::isUniformAfterVectorization [mostly nfc]
authorPhilip Reames <preames@rivosinc.com>
Fri, 26 Aug 2022 17:59:17 +0000 (10:59 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 26 Aug 2022 18:09:17 +0000 (11:09 -0700)
I'd extracted isUniform, and Florian moved isUniformAfterVectorization out of VPlan at basically the same time. Let's go ahead and merge them.

For the VPTransformState::get path, a VPValue without a def (which corresponds to an external IR value outside of VPLan) is explicitly handled above the uniform check.  On the scalarizeInstruction path, I'm less sure why the change isn't visible, but test cases which would seem likely to hit it were already being handled as uniform through some other mechanism.  It would be correct to consider values defined outside of vplan uniform here.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

index 68fab0f..b62e41a 100644 (file)
@@ -2721,14 +2721,6 @@ 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,
@@ -2766,7 +2758,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr,
   for (const auto &I : enumerate(RepRecipe->operands())) {
     auto InputInstance = Instance;
     VPValue *Operand = I.value();
-    if (isUniform(Operand))
+    if (vputils::isUniformAfterVectorization(Operand))
       InputInstance.Lane = VPLane::getFirstLane();
     Cloned->setOperand(I.index(), State.get(Operand, InputInstance));
   }
@@ -9875,7 +9867,7 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part) {
     return ScalarValue;
   }
 
-  bool IsUniform = isUniform(Def);
+  bool IsUniform = vputils::isUniformAfterVectorization(Def);
 
   unsigned LastLane = IsUniform ? 0 : VF.getKnownMinValue() - 1;
   // Check if there is a scalar value for the selected lane.