From b0e58c5528a3bbacb726fcd9934c021863e1c7a8 Mon Sep 17 00:00:00 2001
From: Leon Medvinsky <leonkm2@illinois.edu>
Date: Tue, 19 Apr 2022 11:05:48 -0500
Subject: [PATCH] Fix of previous fix

---
 hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp b/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp
index bceb967dc7..083fe374b2 100644
--- a/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp
+++ b/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp
@@ -1270,7 +1270,8 @@ void hpvm::unrollLoopByCount(Loop *L, LoopInfo &LI, DominatorTree &DT,
 
     // Without this, SE performs no extra analysis and can't determine the
     // recurrence for the induction variable, needed in updateNZLoop
-    SE.forgetLoop(L);
+    if (!L->isInvalid())
+      SE.forgetLoop(L);
 
     if (_AllowRuntime && (_TripCount > 0))
       updateNZLoop(L, LI, SE, F, _Count);
-- 
GitLab