don't load element before checking to see if it is valid.

llvm-svn: 134836
This commit is contained in:
Chris Lattner 2011-07-09 18:23:26 +00:00
parent 60e47d6d24
commit 4f458101b7

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)) {