// 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);