From 71132af89a56f237bc6e18a4e1247b0fc8ee3e6b Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Fri, 11 Feb 2011 06:08:28 +0000 Subject: [PATCH] Make LoopUnswitch preserve ScalarEvolution by just forgetting everything about a loop when unswitching it. It only does this in the complex case, because everything should be fine already in the simple case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125369 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopUnswitch.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 0fc416d6746..b4e3d318a57 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -37,6 +37,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Dominators.h" +#include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -110,6 +111,7 @@ namespace { AU.addRequiredID(LCSSAID); AU.addPreservedID(LCSSAID); AU.addPreserved(); + AU.addPreserved(); } private: @@ -574,6 +576,9 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, << " blocks] in Function " << F->getName() << " when '" << *Val << "' == " << *LIC << "\n"); + if (ScalarEvolution *SE = getAnalysisIfAvailable()) + SE->forgetLoop(L); + LoopBlocks.clear(); NewBlocks.clear();