[llvm] [VPlan] Don't rely on region check in isUniformAfterVectorization. (PR #137883)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 13:30:28 PDT 2025
================
@@ -39,18 +39,37 @@ const SCEV *getSCEVExprForVPValue(VPValue *V, ScalarEvolution &SE);
/// Returns true if \p VPV is uniform after vectorization.
inline bool isUniformAfterVectorization(const VPValue *VPV) {
+ auto IsKnownUniformOpcode = [](auto *R) -> bool {
+ return Instruction::isBinaryOp(R->getOpcode()) ||
+ Instruction::isCast(R->getOpcode()) ||
+ R->getOpcode() == Instruction::GetElementPtr ||
+ R->getOpcode() == Instruction::ICmp ||
+ R->getOpcode() == Instruction::FCmp;
+ };
+
// A value defined outside the vector region must be uniform after
// vectorization inside a vector region.
- if (VPV->isDefinedOutsideLoopRegions())
+ if (VPV->isLiveIn())
return true;
- if (auto *Rep = dyn_cast<VPReplicateRecipe>(VPV))
- return Rep->isUniform();
+ if (auto *Rep = dyn_cast<VPReplicateRecipe>(VPV)) {
+ const VPRegionBlock *ParentR = Rep->getParent()->getParent();
+ return Rep->isUniform() ||
+ (IsKnownUniformOpcode(Rep) &&
+ (!ParentR || !ParentR->isReplicator()) &&
+ all_of(Rep->operands(), isUniformAfterVectorization));
----------------
fhahn wrote:
I moved the check out separately, although no uniform recipes should be in replicate regions
https://github.com/llvm/llvm-project/pull/137883
More information about the llvm-commits
mailing list