diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-08 17:18:01 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-08 17:18:01 +0100 |
commit | 7faad5c90033c56a32b07eac527a456d60ed9a70 (patch) | |
tree | 5646f77275a9b63edb2295053f78781a623a6cf4 /llvm/lib/IR/ConstantFold.cpp | |
parent | f08148e874088a07b972203a183db00de9c38a70 (diff) | |
download | llvm-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.cpp | 2 |
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. |