[llvm] r252152 - [SimplifyCFG] Tweak heuristic for merging conditional stores
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 00:40:20 PST 2015
Author: jamesm
Date: Thu Nov 5 02:40:19 2015
New Revision: 252152
URL: http://llvm.org/viewvc/llvm-project?rev=252152&view=rev
Log:
[SimplifyCFG] Tweak heuristic for merging conditional stores
We were correctly skipping dbginfo intrinsics and terminators, but the initial bailout wasn't, causing it to bail out on almost any block.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=252152&r1=252151&r2=252152&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Thu Nov 5 02:40:19 2015
@@ -2426,14 +2426,20 @@ static bool mergeConditionalStoreToAddre
// Heuristic: if the block can be if-converted/phi-folded and the
// instructions inside are all cheap (arithmetic/GEPs), it's worthwhile to
// thread this store.
- if (BB->size() > PHINodeFoldingThreshold)
- return false;
- for (auto &I : *BB)
- if (!isa<BinaryOperator>(I) && !isa<GetElementPtrInst>(I) &&
- !isa<StoreInst>(I) && !isa<TerminatorInst>(I) &&
- !isa<DbgInfoIntrinsic>(I) && !IsaBitcastOfPointerType(I))
+ unsigned N = 0;
+ for (auto &I : *BB) {
+ // Cheap instructions viable for folding.
+ if (isa<BinaryOperator>(I) || isa<GetElementPtrInst>(I) ||
+ isa<StoreInst>(I))
+ ++N;
+ // Free instructions.
+ else if (isa<TerminatorInst>(I) || isa<DbgInfoIntrinsic>(I) ||
+ IsaBitcastOfPointerType(I))
+ continue;
+ else
return false;
- return true;
+ }
+ return N <= PHINodeFoldingThreshold;
};
if (!MergeCondStoresAggressively && (!IsWorthwhile(PTB) ||
More information about the llvm-commits
mailing list