[llvm-commits] [llvm] r123373 - /llvm/trunk/lib/Analysis/InstructionSimplify.cpp
Duncan Sands
baldrick at free.fr
Thu Jan 13 02:43:08 PST 2011
Author: baldrick
Date: Thu Jan 13 04:43:08 2011
New Revision: 123373
URL: http://llvm.org/viewvc/llvm-project?rev=123373&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=123373&r1=123372&r2=123373&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Jan 13 04:43:08 2011
@@ -1024,12 +1024,15 @@
}
}
- // 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
More information about the llvm-commits
mailing list