Simplify code. NFC.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 2 Mar 2015 11:57:04 +0000 (11:57 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 2 Mar 2015 11:57:04 +0000 (11:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230948 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/IR/Constants.cpp

index 9466f4dd060a2dcb62c3eb64ed04d990084d3514..dcb2ab0a333d0aa8bcb7dc4d3ac7abf3095c8e60 100644 (file)
@@ -5418,17 +5418,9 @@ UpdateNodeOperands(SDNode *N, ArrayRef<SDValue> Ops) {
   assert(N->getNumOperands() == NumOps &&
          "Update with wrong number of operands");
 
-  // Check to see if there is no change.
-  bool AnyChange = false;
-  for (unsigned i = 0; i != NumOps; ++i) {
-    if (Ops[i] != N->getOperand(i)) {
-      AnyChange = true;
-      break;
-    }
-  }
-
-  // No operands changed, just return the input node.
-  if (!AnyChange) return N;
+  // If no operands changed just return the input node.
+  if (std::equal(Ops.begin(), Ops.end(), N->op_begin()))
+    return N;
 
   // See if the modified node already exists.
   void *InsertPos = nullptr;
index 3c6892b019f938fde6daf5b484e6160744d24a72..f5d901c2cc67eff4f45473b662d937ec7c43bce5 100644 (file)
@@ -1215,11 +1215,9 @@ ConstantExpr::getWithOperandReplaced(unsigned OpNo, Constant *Op) const {
 Constant *ConstantExpr::getWithOperands(ArrayRef<Constant *> Ops, Type *Ty,
                                         bool OnlyIfReduced) const {
   assert(Ops.size() == getNumOperands() && "Operand count mismatch!");
-  bool AnyChange = Ty != getType();
-  for (unsigned i = 0; i != Ops.size(); ++i)
-    AnyChange |= Ops[i] != getOperand(i);
 
-  if (!AnyChange)  // No operands changed, return self.
+  // If no operands changed return self.
+  if (Ty == getType() && std::equal(Ops.begin(), Ops.end(), op_begin()))
     return const_cast<ConstantExpr*>(this);
 
   Type *OnlyIfReducedTy = OnlyIfReduced ? Ty : nullptr;