diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-09 18:23:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-09 18:23:26 +0000 |
commit | 822d96bb83ad850c593abedfe026d3432e42b0ed (patch) | |
tree | 3d9d2b7f426617baac0fc845550325bfa2b9d1c7 /llvm/lib/VMCore/ConstantFold.cpp | |
parent | 8e8fd77c7518d38ba0237a432ca7a28942d3cb5d (diff) | |
download | bcm5719-llvm-822d96bb83ad850c593abedfe026d3432e42b0ed.tar.gz bcm5719-llvm-822d96bb83ad850c593abedfe026d3432e42b0ed.zip |
don't load element before checking to see if it is valid.
llvm-svn: 134836
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 2c8f4301763..adbf7fc08bc 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/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)) { |