aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-08 17:18:01 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-08 17:18:01 +0100
commit7faad5c90033c56a32b07eac527a456d60ed9a70 (patch)
tree5646f77275a9b63edb2295053f78781a623a6cf4 /llvm/lib/IR/ConstantFold.cpp
parentf08148e874088a07b972203a183db00de9c38a70 (diff)
downloadllvm-7faad5c90033c56a32b07eac527a456d60ed9a70.zip
llvm-7faad5c90033c56a32b07eac527a456d60ed9a70.tar.gz
llvm-7faad5c90033c56a32b07eac527a456d60ed9a70.tar.bz2
[ConstantFold] Handle icmp of global and null consistently
Return UGT rather than NE for icmp @g, null, which is slightly stronger. This is consistent with what we do for more complex folds. It is somewhat silly that @g ugt null does not get folded while (gep @g) ugt null does.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 2e0ea4c..3701769 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1764,7 +1764,7 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2,
if (!GV->hasExternalWeakLinkage() && !isa<GlobalAlias>(GV) &&
!NullPointerIsDefined(nullptr /* F */,
GV->getType()->getAddressSpace()))
- return ICmpInst::ICMP_NE;
+ return ICmpInst::ICMP_UGT;
}
} else if (const BlockAddress *BA = dyn_cast<BlockAddress>(V1)) {
if (isa<ConstantExpr>(V2)) { // Swap as necessary.