summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2011-03-11 21:52:04 +0000
committerCameron Zwarich <zwarich@apple.com>2011-03-11 21:52:04 +0000
commit899eaa35696bb0a9a625acd70a14876834af6cc5 (patch)
tree3184b26965b0e0ef67ba636e90fa72e4a555b7a6 /lib/Transforms/Scalar/CodeGenPrepare.cpp
parent53aac15a607d66926e586c7fc57634f6be4ef443 (diff)
downloadllvm-899eaa35696bb0a9a625acd70a14876834af6cc5.tar.gz
llvm-899eaa35696bb0a9a625acd70a14876834af6cc5.tar.bz2
llvm-899eaa35696bb0a9a625acd70a14876834af6cc5.tar.xz
Roll r127459 back in:
Optimize trivial branches in CodeGenPrepare, which often get created from the lowering of objectsize intrinsics. Unfortunately, a number of tests were relying on llc not optimizing trivial branches, so I had to add an option to allow them to continue to test what they originally tested. This fixes <rdar://problem/8785296> and <rdar://problem/9112893>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/CodeGenPrepare.cpp')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 887fa9f004..f0babcccee 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -58,6 +58,10 @@ STATISTIC(NumMemoryInsts, "Number of memory instructions whose address "
STATISTIC(NumExtsMoved, "Number of [s|z]ext instructions combined with loads");
STATISTIC(NumExtUses, "Number of uses of [s|z]ext instructions optimized");
+static cl::opt<bool> DisableBranchOpts(
+ "disable-cgp-branch-opts", cl::Hidden, cl::init(false),
+ cl::desc("Disable branch optimizations in CodeGenPrepare"));
+
namespace {
class CodeGenPrepare : public FunctionPass {
/// TLI - Keep a pointer of a TargetLowering to consult for determining
@@ -130,6 +134,16 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
SunkAddrs.clear();
+ if (!DisableBranchOpts) {
+ MadeChange = false;
+ for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
+ MadeChange |= ConstantFoldTerminator(BB);
+
+ if (MadeChange && DT)
+ DT->DT->recalculate(F);
+ EverMadeChange |= MadeChange;
+ }
+
return EverMadeChange;
}