ret i16 addrspace(42)* %a3
}
-define i1 @icmp1(i8* %a) {
-; CHECK-LABEL: @icmp1(
+define i1 @icmp_launder(i8* %a) {
+; CHECK-LABEL: @icmp_launder(
; CHECK-NEXT: [[A2:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* [[A:%.*]])
-; CHECK-NEXT: [[TMP1:%.*]] = call i8* @llvm.strip.invariant.group.p0i8(i8* [[A]])
-; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[A2]], [[TMP1]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[A2]], null
; CHECK-NEXT: ret i1 [[R]]
;
%a2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a)
- %a3 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a2)
- %r = icmp eq i8* %a2, %a3
+ %r = icmp eq i8* %a2, null
ret i1 %r
}
-define i1 @icmp2(i8* %a, i8* %b) {
-; CHECK-LABEL: @icmp2(
-; CHECK-NEXT: [[TMP1:%.*]] = call i8* @llvm.strip.invariant.group.p0i8(i8* [[A:%.*]])
-; CHECK-NEXT: [[TMP2:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* [[B:%.*]])
-; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[TMP1]], [[TMP2]]
+define i1 @icmp_strip(i8* %a) {
+; CHECK-LABEL: @icmp_strip(
+; CHECK-NEXT: [[A2:%.*]] = call i8* @llvm.strip.invariant.group.p0i8(i8* [[A:%.*]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[A2]], null
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %a2 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a)
+ %r = icmp eq i8* %a2, null
+ ret i1 %r
+}
+
+define i1 @icmp_launder_valid_null(i8* %a) #0 {
+; CHECK-LABEL: @icmp_launder_valid_null(
+; CHECK-NEXT: [[A2:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* [[A:%.*]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[A2]], null
; CHECK-NEXT: ret i1 [[R]]
;
%a2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a)
- %a3 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a2)
- %b2 = call i8* @llvm.strip.invariant.group.p0i8(i8* %b)
- %b3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %b2)
- %r = icmp eq i8* %a3, %b3
+ %r = icmp eq i8* %a2, null
+ ret i1 %r
+}
+
+define i1 @icmp_strip_valid_null(i8* %a) #0 {
+; CHECK-LABEL: @icmp_strip_valid_null(
+; CHECK-NEXT: [[A2:%.*]] = call i8* @llvm.strip.invariant.group.p0i8(i8* [[A:%.*]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[A2]], null
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %a2 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a)
+ %r = icmp eq i8* %a2, null
+ ret i1 %r
+}
+
+; Check that null always becomes the RHS
+define i1 @icmp_launder_lhs(i8* %a) {
+; CHECK-LABEL: @icmp_launder_lhs(
+; CHECK-NEXT: [[A2:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* [[A:%.*]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[A2]], null
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %a2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a)
+ %r = icmp eq i8* null, %a2
ret i1 %r
}