From 694e37f08a7c09ccc24642532106295cf7b3a1e3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 17 Aug 2003 19:41:53 +0000 Subject: [PATCH] Fix bug: SimplifyCFG/2003-08-17-BranchFoldOrdering.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7921 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/Local.cpp | 6 ++++++ lib/Transforms/Utils/SimplifyCFG.cpp | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index d3778c50443..3ea76c4ea51 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -74,6 +74,12 @@ bool ConstantFoldTerminator(BasicBlock *BB) { BI->setUnconditionalDest(Dest1); return true; } + } else if (SwitchInst *SI = dyn_cast(TI)) { + if (ConstantInt *CI = dyn_cast(SI->getCondition())) { + + + } + } return false; } diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 1adbef9253a..ed0d45be26b 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -121,6 +121,10 @@ bool SimplifyCFG(BasicBlock *BB) { return true; } + // Check to see if we can constant propagate this terminator instruction + // away... + bool Changed = ConstantFoldTerminator(BB); + // Check to see if this block has no non-phi instructions and only a single // successor. If so, replace references to this basic block with references // to the successor. @@ -251,5 +255,5 @@ bool SimplifyCFG(BasicBlock *BB) { } } - return false; + return Changed; }