1 ; RUN: opt < %s -correlated-propagation -S | FileCheck %s 2 3 define void @test1(i8* %ptr) { 4 ; CHECK: test1 5 %A = load i8, i8* %ptr 6 br label %bb 7 bb: 8 icmp ne i8* %ptr, null 9 ; CHECK-NOT: icmp 10 ret void 11 } 12 13 define void @test2(i8* %ptr) { 14 ; CHECK: test2 15 store i8 0, i8* %ptr 16 br label %bb 17 bb: 18 icmp ne i8* %ptr, null 19 ; CHECK-NOT: icmp 20 ret void 21 } 22 23 define void @test3() { 24 ; CHECK: test3 25 %ptr = alloca i8 26 br label %bb 27 bb: 28 icmp ne i8* %ptr, null 29 ; CHECK-NOT: icmp 30 ret void 31 } 32 33 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) 34 define void @test4(i8* %dest, i8* %src) { 35 ; CHECK: test4 36 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 1, i32 1, i1 false) 37 br label %bb 38 bb: 39 icmp ne i8* %dest, null 40 icmp ne i8* %src, null 41 ; CHECK-NOT: icmp 42 ret void 43 } 44 45 declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) 46 define void @test5(i8* %dest, i8* %src) { 47 ; CHECK: test5 48 call void @llvm.memmove.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 1, i32 1, i1 false) 49 br label %bb 50 bb: 51 icmp ne i8* %dest, null 52 icmp ne i8* %src, null 53 ; CHECK-NOT: icmp 54 ret void 55 } 56 57 declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) 58 define void @test6(i8* %dest) { 59 ; CHECK: test6 60 call void @llvm.memset.p0i8.i32(i8* %dest, i8 255, i32 1, i32 1, i1 false) 61 br label %bb 62 bb: 63 icmp ne i8* %dest, null 64 ; CHECK-NOT: icmp 65 ret void 66 } 67 68 define void @test7(i8* %dest, i8* %src, i32 %len) { 69 ; CHECK: test7 70 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 false) 71 br label %bb 72 bb: 73 %KEEP1 = icmp ne i8* %dest, null 74 ; CHECK: KEEP1 75 %KEEP2 = icmp ne i8* %src, null 76 ; CHECK: KEEP2 77 ret void 78 } 79 80 declare void @llvm.memcpy.p1i8.p1i8.i32(i8 addrspace(1) *, i8 addrspace(1) *, i32, i32, i1) 81 define void @test8(i8 addrspace(1) * %dest, i8 addrspace(1) * %src) { 82 ; CHECK: test8 83 call void @llvm.memcpy.p1i8.p1i8.i32(i8 addrspace(1) * %dest, i8 addrspace(1) * %src, i32 1, i32 1, i1 false) 84 br label %bb 85 bb: 86 %KEEP1 = icmp ne i8 addrspace(1) * %dest, null 87 ; CHECK: KEEP1 88 %KEEP2 = icmp ne i8 addrspace(1) * %src, null 89 ; CHECK: KEEP2 90 ret void 91 } 92 93 define void @test9(i8* %dest, i8* %src) { 94 ; CHECK: test9 95 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 1, i32 1, i1 true) 96 br label %bb 97 bb: 98 %KEEP1 = icmp ne i8* %dest, null 99 ; CHECK: KEEP1 100 %KEEP2 = icmp ne i8* %src, null 101 ; CHECK: KEEP2 102 ret void 103 } 104 105 declare void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg) 106 define void @test10(i8* %arg1, i8* %arg2, i32 %non-pointer-arg) { 107 ; CHECK-LABEL: @test10 108 entry: 109 %is_null = icmp eq i8* %arg1, null 110 br i1 %is_null, label %null, label %non_null 111 112 non_null: 113 call void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg) 114 ; CHECK: call void @test10_helper(i8* nonnull %arg1, i8* %arg2, i32 %non-pointer-arg) 115 br label %null 116 117 null: 118 call void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg) 119 ; CHECK: call void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg) 120 ret void 121 } 122 123 declare void @test11_helper(i8* %arg) 124 define void @test11(i8* %arg1, i8** %arg2) { 125 ; CHECK-LABEL: @test11 126 entry: 127 %is_null = icmp eq i8* %arg1, null 128 br i1 %is_null, label %null, label %non_null 129 130 non_null: 131 br label %merge 132 133 null: 134 %another_arg = alloca i8 135 br label %merge 136 137 merge: 138 %merged_arg = phi i8* [%another_arg, %null], [%arg1, %non_null] 139 call void @test11_helper(i8* %merged_arg) 140 ; CHECK: call void @test11_helper(i8* nonnull %merged_arg) 141 ret void 142 } 143 144 declare void @test12_helper(i8* %arg) 145 define void @test12(i8* %arg1, i8** %arg2) { 146 ; CHECK-LABEL: @test12 147 entry: 148 %is_null = icmp eq i8* %arg1, null 149 br i1 %is_null, label %null, label %non_null 150 151 non_null: 152 br label %merge 153 154 null: 155 %another_arg = load i8*, i8** %arg2, !nonnull !{} 156 br label %merge 157 158 merge: 159 %merged_arg = phi i8* [%another_arg, %null], [%arg1, %non_null] 160 call void @test12_helper(i8* %merged_arg) 161 ; CHECK: call void @test12_helper(i8* nonnull %merged_arg) 162 ret void 163 } 164