}
declare i8* @fn_nonnull_noundef_arg(i8* nonnull noundef %p)
+declare i8* @fn_nonnull_deref_arg(i8* dereferenceable(4) noundef %p)
+declare i8* @fn_nonnull_deref_or_null_arg(i8* dereferenceable_or_null(4) noundef %p)
declare i8* @fn_nonnull_arg(i8* nonnull %p)
declare i8* @fn_noundef_arg(i8* noundef %p)
ret void
}
+; Optimizing this code should produce assume.
+define void @test9_deref(i1 %X, i8* %Y) {
+; CHECK-LABEL: @test9_deref(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[X:%.*]], i8* null, i8* [[Y:%.*]]
+; CHECK-NEXT: [[TMP0:%.*]] = call i8* @fn_nonnull_deref_arg(i8* [[SPEC_SELECT]])
+; CHECK-NEXT: ret void
+;
+entry:
+ br i1 %X, label %if, label %else
+
+if:
+ br label %else
+
+else:
+ %phi = phi i8* [ %Y, %entry ], [ null, %if ]
+ call i8* @fn_nonnull_deref_arg(i8* %phi)
+ ret void
+}
+
+; Optimizing this code should produce assume.
+define void @test9_deref_or_null(i1 %X, i8* %Y) {
+; CHECK-LABEL: @test9_deref_or_null(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[X:%.*]], i8* null, i8* [[Y:%.*]]
+; CHECK-NEXT: [[TMP0:%.*]] = call i8* @fn_nonnull_deref_or_null_arg(i8* [[SPEC_SELECT]])
+; CHECK-NEXT: ret void
+;
+entry:
+ br i1 %X, label %if, label %else
+
+if:
+ br label %else
+
+else:
+ %phi = phi i8* [ %Y, %entry ], [ null, %if ]
+ call i8* @fn_nonnull_deref_or_null_arg(i8* %phi)
+ ret void
+}
+
define void @test9_undef(i1 %X, i8* %Y) {
; CHECK-LABEL: @test9_undef(
; CHECK-NEXT: entry: