1; XFAIL: * 2; RUN: opt < %s -basic-aa -newgvn -S | FileCheck %s 3 4 %struct.anon = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* } 5@debug = external constant i32 ; <i32*> [#uses=0] 6@counters = external constant i32 ; <i32*> [#uses=1] 7@trialx = external global [17 x i32] ; <[17 x i32]*> [#uses=1] 8@dummy1 = external global [7 x i32] ; <[7 x i32]*> [#uses=0] 9@dummy2 = external global [4 x i32] ; <[4 x i32]*> [#uses=0] 10@unacceptable = external global i32 ; <i32*> [#uses=0] 11@isa = external global [13 x %struct.anon] ; <[13 x %struct.anon]*> [#uses=3] 12@.str = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 13@.str1 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 14@.str2 = external constant [1 x i8] ; <[1 x i8]*> [#uses=0] 15@.str3 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 16@.str4 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 17@.str5 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 18@.str6 = external constant [2 x i8] ; <[2 x i8]*> [#uses=0] 19@.str7 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 20@.str8 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 21@.str9 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 22@.str10 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 23@.str11 = external constant [2 x i8] ; <[2 x i8]*> [#uses=0] 24@.str12 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 25@.str13 = external constant [2 x i8] ; <[2 x i8]*> [#uses=0] 26@.str14 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0] 27@.str15 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0] 28@.str16 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 29@.str17 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 30@.str18 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 31@.str19 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 32@.str20 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 33@.str21 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 34@.str22 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 35@.str23 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0] 36@.str24 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 37@.str25 = external constant [6 x i8] ; <[6 x i8]*> [#uses=0] 38@.str26 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0] 39@.str27 = external constant [6 x i8] ; <[6 x i8]*> [#uses=0] 40@r = external global [17 x i32] ; <[17 x i32]*> [#uses=0] 41@.str28 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 42@.str29 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0] 43@pgm = external global [5 x { i32, [3 x i32] }] ; <[5 x { i32, [3 x i32] }]*> [#uses=4] 44@.str30 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 45@.str31 = external constant [13 x i8] ; <[13 x i8]*> [#uses=0] 46@.str32 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 47@.str33 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] 48@.str34 = external constant [20 x i8] ; <[20 x i8]*> [#uses=0] 49@numi = external global i32 ; <i32*> [#uses=7] 50@.str35 = external constant [10 x i8] ; <[10 x i8]*> [#uses=0] 51@counter = external global [5 x i32] ; <[5 x i32]*> [#uses=2] 52@itrialx.2510 = external global i32 ; <i32*> [#uses=0] 53@.str36 = external constant [43 x i8] ; <[43 x i8]*> [#uses=0] 54@.str37 = external constant [42 x i8] ; <[42 x i8]*> [#uses=0] 55@corr_result = external global i32 ; <i32*> [#uses=0] 56@.str38 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0] 57@.str39 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0] 58@.str40 = external constant [47 x i8] ; <[47 x i8]*> [#uses=0] 59@correct_result = external global [17 x i32] ; <[17 x i32]*> [#uses=1] 60@.str41 = external constant [46 x i8] ; <[46 x i8]*> [#uses=0] 61@.str42 = external constant [32 x i8] ; <[32 x i8]*> [#uses=0] 62@.str43 = external constant [44 x i8] ; <[44 x i8]*> [#uses=1] 63@.str44 = external constant [21 x i8] ; <[21 x i8]*> [#uses=1] 64@.str45 = external constant [12 x i8] ; <[12 x i8]*> [#uses=1] 65@.str46 = external constant [5 x i8] ; <[5 x i8]*> [#uses=1] 66@.str47 = external constant [12 x i8] ; <[12 x i8]*> [#uses=1] 67 68declare i32 @neg(i32, i32, i32) 69 70declare i32 @Not(i32, i32, i32) 71 72declare i32 @pop(i32, i32, i32) 73 74declare i32 @nlz(i32, i32, i32) 75 76declare i32 @rev(i32, i32, i32) 77 78declare i32 @add(i32, i32, i32) 79 80declare i32 @sub(i32, i32, i32) 81 82declare i32 @mul(i32, i32, i32) 83 84declare i32 @divide(i32, i32, i32) 85 86declare i32 @divu(i32, i32, i32) 87 88declare i32 @And(i32, i32, i32) 89 90declare i32 @Or(i32, i32, i32) 91 92declare i32 @Xor(i32, i32, i32) 93 94declare i32 @rotl(i32, i32, i32) 95 96declare i32 @shl(i32, i32, i32) 97 98declare i32 @shr(i32, i32, i32) 99 100declare i32 @shrs(i32, i32, i32) 101 102declare i32 @cmpeq(i32, i32, i32) 103 104declare i32 @cmplt(i32, i32, i32) 105 106declare i32 @cmpltu(i32, i32, i32) 107 108declare i32 @seleq(i32, i32, i32) 109 110declare i32 @sellt(i32, i32, i32) 111 112declare i32 @selle(i32, i32, i32) 113 114declare void @print_expr(i32) 115 116declare i32 @printf(i8*, ...) 117 118declare i32 @putchar(i32) 119 120declare void @print_pgm() 121 122declare void @simulate_one_instruction(i32) 123 124declare i32 @check(i32) 125 126declare i32 @puts(i8*) 127 128declare void @fix_operands(i32) 129 130declare void @abort() 131 132declare i32 @increment() 133 134declare i32 @search() 135 136define i32 @main(i32 %argc, i8** %argv) { 137entry: 138 %argc_addr = alloca i32 ; <i32*> [#uses=1] 139 %argv_addr = alloca i8** ; <i8***> [#uses=1] 140 %retval = alloca i32, align 4 ; <i32*> [#uses=2] 141 %tmp = alloca i32, align 4 ; <i32*> [#uses=2] 142 %i = alloca i32, align 4 ; <i32*> [#uses=21] 143 %num_sol = alloca i32, align 4 ; <i32*> [#uses=4] 144 %total = alloca i32, align 4 ; <i32*> [#uses=4] 145 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 146 store i32 %argc, i32* %argc_addr 147 store i8** %argv, i8*** %argv_addr 148 store i32 0, i32* %num_sol 149 store i32 1, i32* @numi 150 br label %bb91 151 152bb: ; preds = %cond_next97 153 %tmp1 = load i32, i32* @numi ; <i32> [#uses=1] 154 %tmp2 = getelementptr [44 x i8], [44 x i8]* @.str43, i32 0, i32 0 ; <i8*> [#uses=1] 155 %tmp3 = call i32 (i8*, ...) @printf( i8* %tmp2, i32 %tmp1 ) ; <i32> [#uses=0] 156 store i32 0, i32* %i 157 br label %bb13 158 159bb4: ; preds = %bb13 160 %tmp5 = load i32, i32* %i ; <i32> [#uses=1] 161 %tmp6 = load i32, i32* %i ; <i32> [#uses=1] 162 %tmp7 = getelementptr [17 x i32], [17 x i32]* @trialx, i32 0, i32 %tmp6 ; <i32*> [#uses=1] 163 %tmp8 = load i32, i32* %tmp7 ; <i32> [#uses=1] 164 %tmp9 = call i32 @userfun( i32 %tmp8 ) ; <i32> [#uses=1] 165 %tmp10 = getelementptr [17 x i32], [17 x i32]* @correct_result, i32 0, i32 %tmp5 ; <i32*> [#uses=1] 166 store i32 %tmp9, i32* %tmp10 167 %tmp11 = load i32, i32* %i ; <i32> [#uses=1] 168 %tmp12 = add i32 %tmp11, 1 ; <i32> [#uses=1] 169 store i32 %tmp12, i32* %i 170 br label %bb13 171 172bb13: ; preds = %bb4, %bb 173 %tmp14 = load i32, i32* %i ; <i32> [#uses=1] 174 %tmp15 = icmp sle i32 %tmp14, 16 ; <i1> [#uses=1] 175 %tmp1516 = zext i1 %tmp15 to i32 ; <i32> [#uses=1] 176 %toBool = icmp ne i32 %tmp1516, 0 ; <i1> [#uses=1] 177 br i1 %toBool, label %bb4, label %bb17 178 179bb17: ; preds = %bb13 180 store i32 0, i32* %i 181 br label %bb49 182 183bb18: ; preds = %bb49 184 %tmp19 = load i32, i32* %i ; <i32> [#uses=1] 185 %tmp20 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp19 ; <{ i32, [3 x i32] }*> [#uses=1] 186 %tmp21 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp20, i32 0, i32 0 ; <i32*> [#uses=1] 187 store i32 0, i32* %tmp21 188 %tmp22 = load i32, i32* %i ; <i32> [#uses=1] 189 %tmp23 = getelementptr [13 x %struct.anon], [13 x %struct.anon]* @isa, i32 0, i32 0 ; <%struct.anon*> [#uses=1] 190 %tmp24 = getelementptr %struct.anon, %struct.anon* %tmp23, i32 0, i32 3 ; <[3 x i32]*> [#uses=1] 191 %tmp25 = getelementptr [3 x i32], [3 x i32]* %tmp24, i32 0, i32 0 ; <i32*> [#uses=1] 192 %tmp26 = load i32, i32* %tmp25 ; <i32> [#uses=1] 193 %tmp27 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp22 ; <{ i32, [3 x i32] }*> [#uses=1] 194 %tmp28 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp27, i32 0, i32 1 ; <[3 x i32]*> [#uses=1] 195 %tmp29 = getelementptr [3 x i32], [3 x i32]* %tmp28, i32 0, i32 0 ; <i32*> [#uses=1] 196 store i32 %tmp26, i32* %tmp29 197 %tmp30 = load i32, i32* %i ; <i32> [#uses=1] 198 %tmp31 = getelementptr [13 x %struct.anon], [13 x %struct.anon]* @isa, i32 0, i32 0 ; <%struct.anon*> [#uses=1] 199 %tmp32 = getelementptr %struct.anon, %struct.anon* %tmp31, i32 0, i32 3 ; <[3 x i32]*> [#uses=1] 200 %tmp33 = getelementptr [3 x i32], [3 x i32]* %tmp32, i32 0, i32 1 ; <i32*> [#uses=1] 201 %tmp34 = load i32, i32* %tmp33 ; <i32> [#uses=1] 202 %tmp35 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp30 ; <{ i32, [3 x i32] }*> [#uses=1] 203 %tmp36 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp35, i32 0, i32 1 ; <[3 x i32]*> [#uses=1] 204 %tmp37 = getelementptr [3 x i32], [3 x i32]* %tmp36, i32 0, i32 1 ; <i32*> [#uses=1] 205 store i32 %tmp34, i32* %tmp37 206 %tmp38 = load i32, i32* %i ; <i32> [#uses=1] 207 %tmp39 = getelementptr [13 x %struct.anon], [13 x %struct.anon]* @isa, i32 0, i32 0 ; <%struct.anon*> [#uses=1] 208 %tmp40 = getelementptr %struct.anon, %struct.anon* %tmp39, i32 0, i32 3 ; <[3 x i32]*> [#uses=1] 209 %tmp41 = getelementptr [3 x i32], [3 x i32]* %tmp40, i32 0, i32 2 ; <i32*> [#uses=1] 210 %tmp42 = load i32, i32* %tmp41 ; <i32> [#uses=1] 211 %tmp43 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp38 ; <{ i32, [3 x i32] }*> [#uses=1] 212 %tmp44 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp43, i32 0, i32 1 ; <[3 x i32]*> [#uses=1] 213 %tmp45 = getelementptr [3 x i32], [3 x i32]* %tmp44, i32 0, i32 2 ; <i32*> [#uses=1] 214 store i32 %tmp42, i32* %tmp45 215 %tmp46 = load i32, i32* %i ; <i32> [#uses=1] 216 call void @fix_operands( i32 %tmp46 ) 217 %tmp47 = load i32, i32* %i ; <i32> [#uses=1] 218; CHECK: %tmp47 = phi i32 [ %tmp48, %bb18 ], [ 0, %bb17 ] 219 %tmp48 = add i32 %tmp47, 1 ; <i32> [#uses=1] 220 store i32 %tmp48, i32* %i 221 br label %bb49 222 223bb49: ; preds = %bb18, %bb17 224 %tmp50 = load i32, i32* @numi ; <i32> [#uses=1] 225 %tmp51 = load i32, i32* %i ; <i32> [#uses=1] 226 %tmp52 = icmp slt i32 %tmp51, %tmp50 ; <i1> [#uses=1] 227 %tmp5253 = zext i1 %tmp52 to i32 ; <i32> [#uses=1] 228 %toBool54 = icmp ne i32 %tmp5253, 0 ; <i1> [#uses=1] 229 br i1 %toBool54, label %bb18, label %bb55 230 231bb55: ; preds = %bb49 232 %tmp56 = call i32 @search( ) ; <i32> [#uses=1] 233 store i32 %tmp56, i32* %num_sol 234 %tmp57 = getelementptr [21 x i8], [21 x i8]* @.str44, i32 0, i32 0 ; <i8*> [#uses=1] 235 %tmp58 = load i32, i32* %num_sol ; <i32> [#uses=1] 236 %tmp59 = call i32 (i8*, ...) @printf( i8* %tmp57, i32 %tmp58 ) ; <i32> [#uses=0] 237 %tmp60 = load i32, i32* @counters ; <i32> [#uses=1] 238 %tmp61 = icmp ne i32 %tmp60, 0 ; <i1> [#uses=1] 239 %tmp6162 = zext i1 %tmp61 to i32 ; <i32> [#uses=1] 240 %toBool63 = icmp ne i32 %tmp6162, 0 ; <i1> [#uses=1] 241 br i1 %toBool63, label %cond_true, label %cond_next 242 243cond_true: ; preds = %bb55 244 store i32 0, i32* %total 245 %tmp64 = getelementptr [12 x i8], [12 x i8]* @.str45, i32 0, i32 0 ; <i8*> [#uses=1] 246 %tmp65 = call i32 (i8*, ...) @printf( i8* %tmp64 ) ; <i32> [#uses=0] 247 store i32 0, i32* %i 248 br label %bb79 249 250bb66: ; preds = %bb79 251 %tmp67 = load i32, i32* %i ; <i32> [#uses=1] 252 %tmp68 = getelementptr [5 x i32], [5 x i32]* @counter, i32 0, i32 %tmp67 ; <i32*> [#uses=1] 253 %tmp69 = load i32, i32* %tmp68 ; <i32> [#uses=1] 254 %tmp70 = getelementptr [5 x i8], [5 x i8]* @.str46, i32 0, i32 0 ; <i8*> [#uses=1] 255 %tmp71 = call i32 (i8*, ...) @printf( i8* %tmp70, i32 %tmp69 ) ; <i32> [#uses=0] 256 %tmp72 = load i32, i32* %i ; <i32> [#uses=1] 257 %tmp73 = getelementptr [5 x i32], [5 x i32]* @counter, i32 0, i32 %tmp72 ; <i32*> [#uses=1] 258 %tmp74 = load i32, i32* %tmp73 ; <i32> [#uses=1] 259 %tmp75 = load i32, i32* %total ; <i32> [#uses=1] 260 %tmp76 = add i32 %tmp74, %tmp75 ; <i32> [#uses=1] 261 store i32 %tmp76, i32* %total 262 %tmp77 = load i32, i32* %i ; <i32> [#uses=1] 263 %tmp78 = add i32 %tmp77, 1 ; <i32> [#uses=1] 264 store i32 %tmp78, i32* %i 265 br label %bb79 266 267bb79: ; preds = %bb66, %cond_true 268 %tmp80 = load i32, i32* @numi ; <i32> [#uses=1] 269 %tmp81 = load i32, i32* %i ; <i32> [#uses=1] 270 %tmp82 = icmp slt i32 %tmp81, %tmp80 ; <i1> [#uses=1] 271 %tmp8283 = zext i1 %tmp82 to i32 ; <i32> [#uses=1] 272 %toBool84 = icmp ne i32 %tmp8283, 0 ; <i1> [#uses=1] 273 br i1 %toBool84, label %bb66, label %bb85 274 275bb85: ; preds = %bb79 276 %tmp86 = getelementptr [12 x i8], [12 x i8]* @.str47, i32 0, i32 0 ; <i8*> [#uses=1] 277 %tmp87 = load i32, i32* %total ; <i32> [#uses=1] 278 %tmp88 = call i32 (i8*, ...) @printf( i8* %tmp86, i32 %tmp87 ) ; <i32> [#uses=0] 279 br label %cond_next 280 281cond_next: ; preds = %bb85, %bb55 282 %tmp89 = load i32, i32* @numi ; <i32> [#uses=1] 283 %tmp90 = add i32 %tmp89, 1 ; <i32> [#uses=1] 284 store i32 %tmp90, i32* @numi 285 br label %bb91 286 287bb91: ; preds = %cond_next, %entry 288 %tmp92 = load i32, i32* @numi ; <i32> [#uses=1] 289 %tmp93 = icmp sgt i32 %tmp92, 5 ; <i1> [#uses=1] 290 %tmp9394 = zext i1 %tmp93 to i32 ; <i32> [#uses=1] 291 %toBool95 = icmp ne i32 %tmp9394, 0 ; <i1> [#uses=1] 292 br i1 %toBool95, label %cond_true96, label %cond_next97 293 294cond_true96: ; preds = %bb91 295 br label %bb102 296 297cond_next97: ; preds = %bb91 298 %tmp98 = load i32, i32* %num_sol ; <i32> [#uses=1] 299 %tmp99 = icmp eq i32 %tmp98, 0 ; <i1> [#uses=1] 300 %tmp99100 = zext i1 %tmp99 to i32 ; <i32> [#uses=1] 301 %toBool101 = icmp ne i32 %tmp99100, 0 ; <i1> [#uses=1] 302 br i1 %toBool101, label %bb, label %bb102 303 304bb102: ; preds = %cond_next97, %cond_true96 305 store i32 0, i32* %tmp 306 %tmp103 = load i32, i32* %tmp ; <i32> [#uses=1] 307 store i32 %tmp103, i32* %retval 308 br label %return 309 310return: ; preds = %bb102 311 %retval104 = load i32, i32* %retval ; <i32> [#uses=1] 312 ret i32 %retval104 313} 314 315declare i32 @userfun(i32) 316