diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 2e0ea4c50e793..37017697f4e18 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. diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll index 41a64205633e2..8698132b87f97 100644 --- a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll +++ b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll @@ -37,7 +37,7 @@ define i1 @ult_constexpr_null(i8* %x) { define i1 @ule_constexpr_null(i8* %x) { ; CHECK-LABEL: @ule_constexpr_null( -; CHECK-NEXT: ret i1 icmp ule (i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), i8 (...)* null) +; CHECK-NEXT: ret i1 false ; %cmp = icmp ule i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), null ret i1 %cmp @@ -76,7 +76,7 @@ define i1 @global_ne_null() { define i1 @global_ugt_null() { ; CHECK-LABEL: @global_ugt_null( -; CHECK-NEXT: ret i1 icmp ugt ([2 x i32]* @g, [2 x i32]* null) +; CHECK-NEXT: ret i1 true ; %cmp = icmp ugt [2 x i32]* @g, null ret i1 %cmp