From 7faad5c90033c56a32b07eac527a456d60ed9a70 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 8 Mar 2021 17:18:01 +0100 Subject: [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. --- llvm/lib/IR/ConstantFold.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/IR/ConstantFold.cpp') 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(GV) && !NullPointerIsDefined(nullptr /* F */, GV->getType()->getAddressSpace())) - return ICmpInst::ICMP_NE; + return ICmpInst::ICMP_UGT; } } else if (const BlockAddress *BA = dyn_cast(V1)) { if (isa(V2)) { // Swap as necessary. -- cgit v1.1