summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-11-05 08:40:19 +0000
committerJames Molloy <james.molloy@arm.com>2015-11-05 08:40:19 +0000
commit9e959ac397bc1a7319b7e06bc4762fc9ca2d0e92 (patch)
tree95a162858a4b68efa5358dd45cdd5894ae323fee /llvm/lib/Transforms
parenta8209d92cca9c6c7f90a98d04dbf14609f2c7b03 (diff)
downloadbcm5719-llvm-9e959ac397bc1a7319b7e06bc4762fc9ca2d0e92.tar.gz
bcm5719-llvm-9e959ac397bc1a7319b7e06bc4762fc9ca2d0e92.zip
[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. llvm-svn: 252152
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 0a0c4a1044a..b119d2df035 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2426,14 +2426,20 @@ static bool mergeConditionalStoreToAddress(BasicBlock *PTB, BasicBlock *PFB,
// 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) ||
OpenPOWER on IntegriCloud