From 011cf687d7d942f41f1cfb3a6fd480898160d4b2 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sun, 14 Jun 2009 22:53:57 +0000 Subject: [PATCH] Check for the short-circuiting condition before performing the potentially expensive erase. llvm-svn: 73359 --- llvm/lib/Analysis/ScalarEvolution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index ee077d56b628..a2ab6e63da6f 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -1012,8 +1012,8 @@ SCEVHandle ScalarEvolution::getAddExpr(SmallVectorImpl &Ops) { // We found two constants, fold them together! Ops[0] = getConstant(LHSC->getValue()->getValue() + RHSC->getValue()->getValue()); + if (Ops.size() == 2) return Ops[0]; Ops.erase(Ops.begin()+1); // Erase the folded element - if (Ops.size() == 1) return Ops[0]; LHSC = cast(Ops[0]); }