mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
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
This commit is contained in:
parent
974dc48135
commit
4634b04513
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user