summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorFiona Glaser <escha@apple.com>2016-03-13 05:36:15 +0000
committerFiona Glaser <escha@apple.com>2016-03-13 05:36:15 +0000
commit2e5c0c2858ca40fdb3cc375955a04ff5a35ee9f6 (patch)
tree4ff67bb06c85258028930c997f68ecce1f138c86 /llvm/lib/Analysis
parent614be596926564664f1e01cfd33372bdbc69c5d8 (diff)
downloadbcm5719-llvm-2e5c0c2858ca40fdb3cc375955a04ff5a35ee9f6.tar.gz
bcm5719-llvm-2e5c0c2858ca40fdb3cc375955a04ff5a35ee9f6.zip
ConstantFoldInstruction: avoid wasted calls to ConstantFoldConstantExpression
Check to see if all operands are constant before calling simplify on them so that we don't perform wasted simplifications. llvm-svn: 263374
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 45988a002aa..9e21a7e3edf 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -983,12 +983,12 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const DataLayout &DL,
// Scan the operand list, checking to see if they are all constants, if so,
// hand off to ConstantFoldInstOperandsImpl.
- SmallVector<Constant*, 8> Ops;
- for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) {
- Constant *Op = dyn_cast<Constant>(*i);
- if (!Op)
- return nullptr; // All operands not constant!
+ if (!all_of(I->operands(), [](Use &U) { return isa<Constant>(U); }))
+ return nullptr;
+ SmallVector<Constant *, 8> Ops;
+ for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) {
+ Constant *Op = cast<Constant>(*i);
// Fold the Instruction's operands.
if (ConstantExpr *NewCE = dyn_cast<ConstantExpr>(Op))
Op = ConstantFoldConstantExpression(NewCE, DL, TLI);
OpenPOWER on IntegriCloud