summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
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
commit338d362200f24e5cb0a3f883067219246dcca208 (patch)
tree9c340487177926cd1adeabf50e2d046250c01714 /llvm/lib/Transforms
parent4d7d728594a0eea417bb7e4c608a19d763e3a822 (diff)
downloadbcm5719-llvm-338d362200f24e5cb0a3f883067219246dcca208.tar.gz
bcm5719-llvm-338d362200f24e5cb0a3f883067219246dcca208.zip
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>. llvm-svn: 127498
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 887fa9f004b..f0babcccee0 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud