From: Chris Lattner Date: Sat, 9 Jul 2011 18:23:26 +0000 (+0000) Subject: don't load element before checking to see if it is valid. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=bda20650d2ec113bd78b8c809dbfafa7f7077152;p=oota-llvm.git don't load element before checking to see if it is valid. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134836 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 2c8f4301763..adbf7fc08bc 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -2172,9 +2172,9 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, bool inBounds, IndexTy const *Idxs, unsigned NumIdx) { + if (NumIdx == 0) return C; Constant *Idx0 = cast(Idxs[0]); - if (NumIdx == 0 || - (NumIdx == 1 && Idx0->isNullValue())) + if ((NumIdx == 1 && Idx0->isNullValue())) return C; if (isa(C)) {