[llvm] [VPlan] Don't rely on region check in isUniformAfterVectorization. (PR #137883)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 1 00:22:39 PDT 2025
================
@@ -39,19 +39,43 @@ const SCEV *getSCEVExprForVPValue(VPValue *V, ScalarEvolution &SE);
/// Returns true if \p VPV is uniform after vectorization.
inline bool isUniformAfterVectorization(const VPValue *VPV) {
- // A value defined outside the vector region must be uniform after
- // vectorization inside a vector region.
- if (VPV->isDefinedOutsideLoopRegions())
+ auto PreservesUniformity = [](unsigned Opcode) -> bool {
+ if (Instruction::isBinaryOp(Opcode) || Instruction::isCast(Opcode))
+ return true;
+ switch (Opcode) {
+ case Instruction::GetElementPtr:
+ case Instruction::ICmp:
+ case Instruction::FCmp:
+ case VPInstruction::Broadcast:
+ case VPInstruction::PtrAdd:
+ return true;
+ default:
+ return false;
+ }
+ };
+
+ // A live-in must be uniform across the scope of VPlan.
+ if (VPV->isLiveIn())
return true;
- if (auto *Rep = dyn_cast<VPReplicateRecipe>(VPV))
- return Rep->isUniform();
+
+ if (auto *Rep = dyn_cast<VPReplicateRecipe>(VPV)) {
+ const VPRegionBlock *RegionOfR = Rep->getParent()->getParent();
+ if (RegionOfR && RegionOfR->isReplicator())
+ return false;
----------------
ayalz wrote:
Maybe worth a comment - it's ok functionally to sink uniform/after-vectorization recipes into replicate regions, we avoid doing so due to cost considerations. Here an early exit condition is introduced before checking operands recursively - another cost rather than functional decision - could do w/o the replicate region check?
Note that prior to introducing replicate regions, the recipes they are to include can (and should?) be identified by isPredicated().
https://github.com/llvm/llvm-project/pull/137883
More information about the llvm-commits
mailing list