[llvm] [LV][NFC] Refactor structures used to maintain uncountable exit info (PR #123219)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 07:19:33 PST 2025


================
@@ -391,25 +391,22 @@ class LoopVectorizationLegality {
 
   /// Returns true if the loop has an uncountable early exit, i.e. an
   /// uncountable exit that isn't the latch block.
-  bool hasUncountableEarlyExit() const { return HasUncountableEarlyExit; }
+  bool hasUncountableEarlyExit() const {
+    return getUncountableEdge().has_value();
+  }
 
   /// Returns the uncountable early exiting block.
   BasicBlock *getUncountableEarlyExitingBlock() const {
-    if (!HasUncountableEarlyExit) {
-      assert(getUncountableExitingBlocks().empty() &&
-             "Expected no uncountable exiting blocks");
+    if (!hasUncountableEarlyExit())
       return nullptr;
-    }
-    assert(getUncountableExitingBlocks().size() == 1 &&
-           "Expected only a single uncountable exiting block");
-    return getUncountableExitingBlocks()[0];
+    return (*getUncountableEdge()).first;
   }
 
   /// Returns the destination of an uncountable early exiting block.
----------------
fhahn wrote:

```suggestion
  /// Returns the destination of the uncountable early exiting block, there is a single one.
```

https://github.com/llvm/llvm-project/pull/123219


More information about the llvm-commits mailing list