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.
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.
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
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