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
This commit is contained in:
Chris Lattner 2011-07-09 18:23:26 +00:00
parent 145ab10711
commit bda20650d2

View File

@ -2172,9 +2172,9 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C,
bool inBounds,
IndexTy const *Idxs,
unsigned NumIdx) {
if (NumIdx == 0) return C;
Constant *Idx0 = cast<Constant>(Idxs[0]);
if (NumIdx == 0 ||
(NumIdx == 1 && Idx0->isNullValue()))
if ((NumIdx == 1 && Idx0->isNullValue()))
return C;
if (isa<UndefValue>(C)) {