[PATCH] D27111: Enable aggressive hoisting when optimizing for code-size.
Aditya Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 29 06:44:10 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288141: [GVNHoist] Enable aggressive hoisting when optimizing for code-size (authored by hiraditya).
Changed prior to commit:
https://reviews.llvm.org/D27111?vs=79248&id=79563#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27111
Files:
llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
Index: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
@@ -202,7 +202,12 @@
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 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27111.79563.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161129/a7803332/attachment-0001.bin>
More information about the llvm-commits
mailing list