[llvm] [VPlan] Don't rely on region check in isUniformAfterVectorization. (PR #137883)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 06:10:27 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;
----------------
fhahn wrote:
Yep, we could consider them uniform, the main issue is that this is also used when executing replicate recipes to see if we can simply retrieve the first lane; but that's not possible for replicate regions, as the uniform value created for lane 0 won't dominate the user when executing the region for lane 1 and so on. added a comment
https://github.com/llvm/llvm-project/pull/137883
More information about the llvm-commits
mailing list