1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
4 declare void @zero_args()
5 declare void @two_args(ptr, ptr)
7 ; TODO: Could be non-null based on call-site attributes.
8 define i1 @test_zero_args_nonnull(ptr %p) {
9 ; CHECK-LABEL: @test_zero_args_nonnull(
10 ; CHECK-NEXT: call void @zero_args(ptr noundef nonnull [[P:%.*]])
11 ; CHECK-NEXT: [[C:%.*]] = icmp ne ptr [[P]], null
12 ; CHECK-NEXT: ret i1 [[C]]
14 call void @zero_args(ptr nonnull noundef %p)
15 %c = icmp ne ptr %p, null
19 define i1 @test_zero_args_maybe_null(ptr %p) {
20 ; CHECK-LABEL: @test_zero_args_maybe_null(
21 ; CHECK-NEXT: call void @zero_args(ptr [[P:%.*]])
22 ; CHECK-NEXT: [[C:%.*]] = icmp ne ptr [[P]], null
23 ; CHECK-NEXT: ret i1 [[C]]
25 call void @zero_args(ptr %p)
26 %c = icmp ne ptr %p, null
30 ; TODO: Could be non-null based on call-site attributes.
31 define i1 @test_two_args_nonnull(ptr %p) {
32 ; CHECK-LABEL: @test_two_args_nonnull(
33 ; CHECK-NEXT: call void @two_args(ptr noundef nonnull [[P:%.*]])
34 ; CHECK-NEXT: [[C:%.*]] = icmp ne ptr [[P]], null
35 ; CHECK-NEXT: ret i1 [[C]]
37 call void @two_args(ptr nonnull noundef %p)
38 %c = icmp ne ptr %p, null
42 define i1 @test_two_args_maybe_null(ptr %p) {
43 ; CHECK-LABEL: @test_two_args_maybe_null(
44 ; CHECK-NEXT: call void @two_args(ptr [[P:%.*]])
45 ; CHECK-NEXT: [[C:%.*]] = icmp ne ptr [[P]], null
46 ; CHECK-NEXT: ret i1 [[C]]
48 call void @two_args(ptr %p)
49 %c = icmp ne ptr %p, null