summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorAditya Kumar <hiraditya@msn.com>2016-11-29 14:34:01 +0000
committerAditya Kumar <hiraditya@msn.com>2016-11-29 14:34:01 +0000
commit07cb3048262b8219ee59f876f1470014bc8aa41f (patch)
tree435f57c04817019636ca841e2c543a82f17a568b /llvm/lib/Transforms/Scalar
parent35c47c494d58af1ed41934f49ea40484238f73eb (diff)
downloadbcm5719-llvm-07cb3048262b8219ee59f876f1470014bc8aa41f.tar.gz
bcm5719-llvm-07cb3048262b8219ee59f876f1470014bc8aa41f.zip
[GVNHoist] Enable aggressive hoisting when optimizing for code-size
Enable scalar hoisting at -Oz as it is safe to hoist scalars to a place where they are partially needed. Differential Revision: https://reviews.llvm.org/D27111 llvm-svn: 288141
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 7de1b37df19..5b2f1b6277f 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -202,7 +202,12 @@ public:
GVNHoist(DominatorTree *DT, AliasAnalysis *AA, MemoryDependenceResults *MD,
MemorySSA *MSSA, bool OptForMinSize)
: DT(DT), AA(AA), MD(MD), MSSA(MSSA), OptForMinSize(OptForMinSize),
- HoistingGeps(OptForMinSize), HoistedCtr(0) {}
+ HoistingGeps(OptForMinSize), HoistedCtr(0) {
+ // Hoist as far as possible when optimizing for code-size.
+ if (OptForMinSize)
+ MaxNumberOfBBSInPath = -1;
+ }
+
bool run(Function &F) {
VN.setDomTree(DT);
VN.setAliasAnalysis(AA);
@@ -500,10 +505,13 @@ private:
bool safeToHoistScalar(const BasicBlock *HoistBB,
SmallPtrSetImpl<const BasicBlock *> &WL,
int &NBBsOnAllPaths) {
- // Check that the hoisted expression is needed on all paths. Enable scalar
- // hoisting at -Oz as it is safe to hoist scalars to a place where they are
- // partially needed.
- if (!OptForMinSize && !hoistingFromAllPaths(HoistBB, WL))
+ // Enable scalar hoisting at -Oz as it is safe to hoist scalars to a place
+ // where they are partially needed.
+ if (OptForMinSize)
+ return true;
+
+ // Check that the hoisted expression is needed on all paths.
+ if (!hoistingFromAllPaths(HoistBB, WL))
return false;
for (const BasicBlock *BB : WL)
OpenPOWER on IntegriCloud