aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-09 18:23:26 +0000
committerChris Lattner <sabre@nondot.org>2011-07-09 18:23:26 +0000
commitbda20650d2ec113bd78b8c809dbfafa7f7077152 (patch)
tree132720bdfa231994b144fece9d3a8e395b0bff7f /lib/VMCore/ConstantFold.cpp
parent145ab1071123c711242ac665bdcf80004f504d9b (diff)
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
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 2c8f430176..adbf7fc08b 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<Constant>(Idxs[0]);
- if (NumIdx == 0 ||
- (NumIdx == 1 && Idx0->isNullValue()))
+ if ((NumIdx == 1 && Idx0->isNullValue()))
return C;
if (isa<UndefValue>(C)) {