diff options
author | Duncan Sands <baldrick@free.fr> | 2011-01-13 10:43:08 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2011-01-13 10:43:08 +0000 |
commit | 53ad861193e44454cd3051ddb34fae398827ab6c (patch) | |
tree | b032b95c969c53fdec914e498d89aa0aba63d7db /lib/Analysis/InstructionSimplify.cpp | |
parent | 6dc91253ab1872e118b08511a09d5c934988354e (diff) | |
download | external_llvm-53ad861193e44454cd3051ddb34fae398827ab6c.zip external_llvm-53ad861193e44454cd3051ddb34fae398827ab6c.tar.gz external_llvm-53ad861193e44454cd3051ddb34fae398827ab6c.tar.bz2 |
Remove some wrong code which fortunately was never executed (as explained in
the comment I added): an extern weak global may have a null address.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index b3a3aca..d4b89ce 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -1024,12 +1024,15 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, } } - // icmp <global/alloca*/null>, <global/alloca*/null> - Global/Stack value - // addresses never equal each other! We already know that Op0 != Op1. - if ((isa<GlobalValue>(LHS) || isa<AllocaInst>(LHS) || - isa<ConstantPointerNull>(LHS)) && - (isa<GlobalValue>(RHS) || isa<AllocaInst>(RHS) || - isa<ConstantPointerNull>(RHS))) + // icmp <alloca*>, <global/alloca*/null> - Different stack variables have + // different addresses, and what's more the address of a stack variable is + // never null or equal to the address of a global. Note that generalizing + // to the case where LHS is a global variable address or null is pointless, + // since if both LHS and RHS are constants then we already constant folded + // the compare, and if only one of them is then we moved it to RHS already. + if (isa<AllocaInst>(LHS) && (isa<GlobalValue>(RHS) || isa<AllocaInst>(RHS) || + isa<ConstantPointerNull>(RHS))) + // We already know that LHS != LHS. return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred)); // If the comparison is with the result of a select instruction, check whether |