diff --git a/lib/Analysis/ValueNumbering.cpp b/lib/Analysis/ValueNumbering.cpp index 1e4b306f62e..98f04bd06e1 100644 --- a/lib/Analysis/ValueNumbering.cpp +++ b/lib/Analysis/ValueNumbering.cpp @@ -244,9 +244,9 @@ void BVNImpl::visitGetElementPtrInst(GetElementPtrInst &I) { // Try to pick a local operand if possible instead of a constant or a global // that might have a lot of uses. - for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i) - if (isa(I.getOperand(i)) || isa(I.getOperand(i))) { - Op = I.getOperand(i); + for (User::op_iterator i = I.op_begin() + 1, e = I.op_end(); i != e; ++i) + if (isa(*i) || isa(*i)) { + Op = *i; break; }