1 ; RUN: opt < %s -ipsccp -S | FileCheck %s 2 3 ;;======================== test1 4 5 define internal i32 @test1a(i32 %A) { 6 %X = add i32 1, 2 7 ret i32 %A 8 } 9 ; CHECK-LABEL: define internal i32 @test1a( 10 ; CHECK: ret i32 undef 11 12 define i32 @test1b() { 13 %X = call i32 @test1a( i32 17 ) 14 ret i32 %X 15 16 ; CHECK-LABEL: define i32 @test1b( 17 ; CHECK: ret i32 17 18 } 19 20 21 22 ;;======================== test2 23 24 define internal i32 @test2a(i32 %A) { 25 %C = icmp eq i32 %A, 0 26 br i1 %C, label %T, label %F 27 T: 28 %B = call i32 @test2a( i32 0 ) 29 ret i32 0 30 F: 31 %C.upgrd.1 = call i32 @test2a(i32 1) 32 ret i32 %C.upgrd.1 33 } 34 ; CHECK-LABEL: define internal i32 @test2a( 35 ; CHECK-NEXT: br label %T 36 ; CHECK: ret i32 undef 37 38 39 define i32 @test2b() { 40 %X = call i32 @test2a(i32 0) 41 ret i32 %X 42 } 43 ; CHECK-LABEL: define i32 @test2b( 44 ; CHECK-NEXT: %X = call i32 @test2a(i32 0) 45 ; CHECK-NEXT: ret i32 0 46 47 48 ;;======================== test3 49 50 @G = internal global i32 undef 51 52 define void @test3a() { 53 %X = load i32, i32* @G 54 store i32 %X, i32* @G 55 ret void 56 } 57 ; CHECK-LABEL: define void @test3a( 58 ; CHECK-NEXT: ret void 59 60 61 define i32 @test3b() { 62 %V = load i32, i32* @G 63 %C = icmp eq i32 %V, 17 64 br i1 %C, label %T, label %F 65 T: 66 store i32 17, i32* @G 67 ret i32 %V 68 F: 69 store i32 123, i32* @G 70 ret i32 0 71 } 72 ; CHECK-LABEL: define i32 @test3b( 73 ; CHECK-NOT: store 74 ; CHECK: ret i32 0 75 76 77 ;;======================== test4 78 79 define internal {i64,i64} @test4a() { 80 %a = insertvalue {i64,i64} undef, i64 4, 1 81 %b = insertvalue {i64,i64} %a, i64 5, 0 82 ret {i64,i64} %b 83 } 84 85 define i64 @test4b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 86 %a = invoke {i64,i64} @test4a() 87 to label %A unwind label %B 88 A: 89 %b = extractvalue {i64,i64} %a, 0 90 %c = call i64 @test4c(i64 %b) 91 ret i64 %c 92 B: 93 %val = landingpad { i8*, i32 } 94 catch i8* null 95 ret i64 0 96 } 97 ; CHECK: define i64 @test4b() 98 ; CHECK: %c = call i64 @test4c(i64 5) 99 ; CHECK-NEXT: ret i64 5 100 101 102 define internal i64 @test4c(i64 %a) { 103 ret i64 %a 104 } 105 ; CHECK-LABEL: define internal i64 @test4c( 106 ; CHECK: ret i64 undef 107 108 109 110 ;;======================== test5 111 112 ; PR4313 113 define internal {i64,i64} @test5a() { 114 %a = insertvalue {i64,i64} undef, i64 4, 1 115 %b = insertvalue {i64,i64} %a, i64 5, 0 116 ret {i64,i64} %b 117 } 118 119 define i64 @test5b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 120 %a = invoke {i64,i64} @test5a() 121 to label %A unwind label %B 122 A: 123 %c = call i64 @test5c({i64,i64} %a) 124 ret i64 %c 125 B: 126 %val = landingpad { i8*, i32 } 127 catch i8* null 128 ret i64 0 129 } 130 131 ; CHECK: define i64 @test5b() 132 ; CHECK: A: 133 ; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } %a) 134 ; CHECK-NEXT: ret i64 5 135 136 define internal i64 @test5c({i64,i64} %a) { 137 %b = extractvalue {i64,i64} %a, 0 138 ret i64 %b 139 } 140 141 142 ;;======================== test6 143 144 define i64 @test6a() { 145 ret i64 0 146 } 147 148 define i64 @test6b() { 149 %a = call i64 @test6a() 150 ret i64 %a 151 } 152 ; CHECK-LABEL: define i64 @test6b( 153 ; CHECK: ret i64 0 154 155 ;;======================== test7 156 157 158 %T = type {i32,i32} 159 160 define internal %T @test7a(i32 %A) { 161 %X = add i32 1, %A 162 %mrv0 = insertvalue %T undef, i32 %X, 0 163 %mrv1 = insertvalue %T %mrv0, i32 %A, 1 164 ret %T %mrv1 165 ; CHECK-LABEL: @test7a( 166 ; CHECK-NEXT: %mrv0 = insertvalue %T undef, i32 18, 0 167 ; CHECK-NEXT: %mrv1 = insertvalue %T %mrv0, i32 17, 1 168 } 169 170 define i32 @test7b() { 171 %X = call %T @test7a(i32 17) 172 %Y = extractvalue %T %X, 0 173 %Z = add i32 %Y, %Y 174 ret i32 %Z 175 ; CHECK-LABEL: define i32 @test7b( 176 ; CHECK-NEXT: call %T @test7a(i32 17) 177 ; CHECK-NEXT: ret i32 36 178 } 179 180 ;;======================== test8 181 182 183 define internal {} @test8a(i32 %A, i32* %P) { 184 store i32 %A, i32* %P 185 ret {} {} 186 ; CHECK-LABEL: @test8a( 187 ; CHECK-NEXT: store i32 5, 188 ; CHECK-NEXT: ret 189 } 190 191 define void @test8b(i32* %P) { 192 %X = call {} @test8a(i32 5, i32* %P) 193 ret void 194 ; CHECK-LABEL: define void @test8b( 195 ; CHECK-NEXT: call {} @test8a 196 ; CHECK-NEXT: ret void 197 } 198 199 ;;======================== test9 200 201 @test9g = internal global { } zeroinitializer 202 203 define void @test9() { 204 entry: 205 %local_foo = alloca { } 206 load { }, { }* @test9g 207 store { } %0, { }* %local_foo 208 ret void 209 } 210 211 declare i32 @__gxx_personality_v0(...) 212 213 ;;======================== test10 214 215 define i32 @test10a() nounwind { 216 entry: 217 %call = call i32 @test10b(i32 undef) 218 ret i32 %call 219 ; CHECK-LABEL: define i32 @test10a( 220 ; CHECK: ret i32 0 221 } 222 223 define internal i32 @test10b(i32 %x) nounwind { 224 entry: 225 %r = and i32 %x, 1 226 ret i32 %r 227 ; CHECK-LABEL: define internal i32 @test10b( 228 ; CHECK: ret i32 undef 229 } 230 231 ;;======================== test11 232 233 define i64 @test11a() { 234 %xor = xor i64 undef, undef 235 ret i64 %xor 236 ; CHECK-LABEL: define i64 @test11a 237 ; CHECK: ret i64 0 238 } 239 240 define void @test11b() { 241 %call1 = call i64 @test11a() 242 %call2 = call i64 @llvm.ctpop.i64(i64 %call1) 243 ret void 244 ; CHECK-LABEL: define void @test11b 245 ; CHECK: %[[call1:.*]] = call i64 @test11a() 246 ; CHECK: %[[call2:.*]] = call i64 @llvm.ctpop.i64(i64 0) 247 } 248 249 declare i64 @llvm.ctpop.i64(i64) 250