From 42641ac79d23f5369fa64404c4b16e84748a84be Mon Sep 17 00:00:00 2001
From: Leon Medvinsky <leonkm2@illinois.edu>
Date: Tue, 19 Apr 2022 10:36:03 -0500
Subject: [PATCH] Fix crash in unroll

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

diff --git a/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp b/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp
index bcb7211bae..bceb967dc7 100644
--- a/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp
+++ b/hpvm/lib/Transforms/Utils/HPVMLoopTransforms.cpp
@@ -1268,6 +1268,10 @@ void hpvm::unrollLoopByCount(Loop *L, LoopInfo &LI, DominatorTree &DT,
     hpvmUnrollLoop(L, ULO, &LI, &SE, &DT, &AC, &ORE, &TTI, _TripCount, _TripMultiple,
       _PreserveLCSSA);
 
+    // Without this, SE performs no extra analysis and can't determine the
+    // recurrence for the induction variable, needed in updateNZLoop
+    SE.forgetLoop(L);
+
     if (_AllowRuntime && (_TripCount > 0))
       updateNZLoop(L, LI, SE, F, _Count);
   }
-- 
GitLab