[llvm] [VPlan] Replace VPRegionBlock with explicit CFG before execute (NFCI). (PR #117506)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 04:37:54 PDT 2025
================
@@ -1365,17 +1397,18 @@ void VPlanPrinter::dumpRegion(const VPRegionBlock *Region) {
#endif
-/// Returns true if there is a vector loop region and \p VPV is defined in a
-/// loop region.
-static bool isDefinedInsideLoopRegions(const VPValue *VPV) {
- const VPRecipeBase *DefR = VPV->getDefiningRecipe();
- return DefR && (!DefR->getParent()->getPlan()->getVectorLoopRegion() ||
- DefR->getParent()->getEnclosingLoopRegion());
-}
+bool VPValue::isDefinedOutsideLoop() const {
+ auto *DefR = getDefiningRecipe();
+ if (!DefR)
+ return true;
-bool VPValue::isDefinedOutsideLoopRegions() const {
- return !isDefinedInsideLoopRegions(this);
+ // For non-live-ins, check if is in a region only if the top-level loop region
+ // still exits.
+ const VPBasicBlock *DefVPBB = DefR->getParent();
+ auto *Plan = DefVPBB->getPlan();
+ return Plan->getVectorLoopRegion() && !DefVPBB->getEnclosingLoopRegion();
----------------
ayalz wrote:
De Morgan'izing previous `isDefinedOutsideLoopRegions()`:
```
!(DefR && (!DefR->getParent()->getPlan()->getVectorLoopRegion() ||
DefR->getParent()->getEnclosingLoopRegion()))
==
!DefR || !(!DefR->getParent()->getPlan()->getVectorLoopRegion() ||
DefR->getParent()->getEnclosingLoopRegion())
==
!DefR || (DefR->getParent()->getPlan()->getVectorLoopRegion() &&
!DefR->getParent()->getEnclosingLoopRegion())
```
which appears to be what the current `isDefinedOutsideLoop()` is doing?
This is already conservative in the sense that answering **false** means it **may** be defined inside loops - those that remain after loop regions are removed? Perhaps more accurately called `mustBeDefinedOutsideLoops()`, instead of negating `isDefinedInsideLoopRegions()` which is precisely documented to return "true if there is a vector loop region and \p VPV is defined in a loop region".
https://github.com/llvm/llvm-project/pull/117506
More information about the llvm-commits
mailing list