1 ; This is a smoke test for reordering pooled constants. 2 ; This option is only implemented for target X8632 for now. 3 4 ; RUN: %p2i --assemble --disassemble --filetype=obj --dis-flags=-s \ 5 ; RUN: --target x8632 -i %s --args -sz-seed=1 -O2 -reorder-pooled-constants \ 6 ; RUN: -allow-externally-defined-symbols | FileCheck %s --check-prefix=X86 7 8 ; RUN: %p2i --assemble --disassemble --filetype=obj --dis-flags=-s \ 9 ; RUN: --target x8632 -i %s --args -sz-seed=1 -Om1 -reorder-pooled-constants \ 10 ; RUN: -allow-externally-defined-symbols | FileCheck %s --check-prefix=X86 11 12 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 13 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 14 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 15 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 16 17 define internal float @FpLookup1(i32 %Arg) { 18 entry: 19 switch i32 %Arg, label %return [ 20 i32 0, label %sw.bb 21 i32 1, label %sw.bb1 22 i32 2, label %sw.bb4 23 i32 3, label %sw.bb7 24 i32 -1, label %sw.bb10 25 i32 -2, label %sw.bb14 26 i32 -3, label %sw.bb19 27 i32 10, label %sw.bb24 28 i32 -10, label %sw.bb27 29 i32 100, label %sw.bb30 30 i32 101, label %sw.bb33 31 i32 102, label %sw.bb36 32 i32 103, label %sw.bb39 33 i32 -101, label %sw.bb42 34 i32 -102, label %sw.bb47 35 i32 -103, label %sw.bb52 36 i32 110, label %sw.bb57 37 i32 -110, label %sw.bb60 38 ] 39 40 sw.bb: ; preds = %entry 41 %call = call float @Dummy(i32 0) 42 %add = fadd float %call, 1.000000e+00 43 br label %return 44 45 sw.bb1: ; preds = %entry 46 %call2 = call float @Dummy(i32 1) 47 %add3 = fadd float %call2, 2.000000e+00 48 br label %return 49 50 sw.bb4: ; preds = %entry 51 %call5 = call float @Dummy(i32 2) 52 %add6 = fadd float %call5, 4.000000e+00 53 br label %return 54 55 sw.bb7: ; preds = %entry 56 %call8 = call float @Dummy(i32 3) 57 %add9 = fadd float %call8, 8.000000e+00 58 br label %return 59 60 sw.bb10: ; preds = %entry 61 %call11 = call float @Dummy(i32 -1) 62 %conv13 = fadd float %call11, 5.000000e-01 63 br label %return 64 65 sw.bb14: ; preds = %entry 66 %call15 = call float @Dummy(i32 -2) 67 %conv16 = fpext float %call15 to double 68 %add17 = fadd double %conv16, 0x3FD5555555555555 69 %conv18 = fptrunc double %add17 to float 70 br label %return 71 72 sw.bb19: ; preds = %entry 73 %call20 = call float @Dummy(i32 -3) 74 %conv23 = fadd float %call20, 2.500000e-01 75 br label %return 76 77 sw.bb24: ; preds = %entry 78 %call25 = call float @Dummy(i32 10) 79 %add26 = fadd float %call25, 0x7FF8000000000000 80 br label %return 81 82 sw.bb27: ; preds = %entry 83 %call28 = call float @Dummy(i32 -10) 84 %add29 = fadd float %call28, 0xFFF8000000000000 85 br label %return 86 87 sw.bb30: ; preds = %entry 88 %call31 = call float @Dummy(i32 100) 89 %add32 = fadd float %call31, 1.000000e+00 90 br label %return 91 92 sw.bb33: ; preds = %entry 93 %call34 = call float @Dummy(i32 101) 94 %add35 = fadd float %call34, 2.000000e+00 95 br label %return 96 97 sw.bb36: ; preds = %entry 98 %call37 = call float @Dummy(i32 102) 99 %add38 = fadd float %call37, 4.000000e+00 100 br label %return 101 102 sw.bb39: ; preds = %entry 103 %call40 = call float @Dummy(i32 103) 104 %add41 = fadd float %call40, 8.000000e+00 105 br label %return 106 107 sw.bb42: ; preds = %entry 108 %call43 = call float @Dummy(i32 -101) 109 %conv46 = fadd float %call43, 5.000000e-01 110 br label %return 111 112 sw.bb47: ; preds = %entry 113 %call48 = call float @Dummy(i32 -102) 114 %conv49 = fpext float %call48 to double 115 %add50 = fadd double %conv49, 0x3FD5555555555555 116 %conv51 = fptrunc double %add50 to float 117 br label %return 118 119 sw.bb52: ; preds = %entry 120 %call53 = call float @Dummy(i32 -103) 121 %conv56 = fadd float %call53, 2.500000e-01 122 br label %return 123 124 sw.bb57: ; preds = %entry 125 %call58 = call float @Dummy(i32 110) 126 %add59 = fadd float %call58, 0x7FF8000000000000 127 br label %return 128 129 sw.bb60: ; preds = %entry 130 %call61 = call float @Dummy(i32 -110) 131 %add62 = fadd float %call61, 0xFFF8000000000000 132 br label %return 133 134 return: ; preds = %entry, %sw.bb60, %sw.bb57, %sw.bb52, %sw.bb47, %sw.bb42, %sw.bb39, %sw.bb36, %sw.bb33, %sw.bb30, %sw.bb27, %sw.bb24, %sw.bb19, %sw.bb14, %sw.bb10, %sw.bb7, %sw.bb4, %sw.bb1, %sw.bb 135 %retval.0 = phi float [ %add62, %sw.bb60 ], [ %add59, %sw.bb57 ], [ %conv56, %sw.bb52 ], [ %conv51, %sw.bb47 ], [ %conv46, %sw.bb42 ], [ %add41, %sw.bb39 ], [ %add38, %sw.bb36 ], [ %add35, %sw.bb33 ], [ %add32, %sw.bb30 ], [ %add29, %sw.bb27 ], [ %add26, %sw.bb24 ], [ %conv23, %sw.bb19 ], [ %conv18, %sw.bb14 ], [ %conv13, %sw.bb10 ], [ %add9, %sw.bb7 ], [ %add6, %sw.bb4 ], [ %add3, %sw.bb1 ], [ %add, %sw.bb ], [ 0.000000e+00, %entry ] 136 ret float %retval.0 137 } 138 139 declare float @Dummy(i32) 140 141 define internal float @FpLookup2(i32 %Arg) { 142 entry: 143 switch i32 %Arg, label %return [ 144 i32 0, label %sw.bb 145 i32 1, label %sw.bb1 146 i32 2, label %sw.bb4 147 i32 3, label %sw.bb7 148 i32 -1, label %sw.bb10 149 i32 -2, label %sw.bb14 150 i32 -3, label %sw.bb19 151 i32 10, label %sw.bb24 152 i32 -10, label %sw.bb27 153 i32 100, label %sw.bb30 154 i32 101, label %sw.bb33 155 i32 102, label %sw.bb36 156 i32 103, label %sw.bb39 157 i32 -101, label %sw.bb42 158 i32 -102, label %sw.bb47 159 i32 -103, label %sw.bb52 160 i32 110, label %sw.bb57 161 i32 -110, label %sw.bb60 162 ] 163 164 sw.bb: ; preds = %entry 165 %call = call float @Dummy(i32 0) 166 %add = fadd float %call, 1.000000e+00 167 br label %return 168 169 sw.bb1: ; preds = %entry 170 %call2 = call float @Dummy(i32 1) 171 %add3 = fadd float %call2, 2.000000e+00 172 br label %return 173 174 sw.bb4: ; preds = %entry 175 %call5 = call float @Dummy(i32 2) 176 %add6 = fadd float %call5, 4.000000e+00 177 br label %return 178 179 sw.bb7: ; preds = %entry 180 %call8 = call float @Dummy(i32 3) 181 %add9 = fadd float %call8, 8.000000e+00 182 br label %return 183 184 sw.bb10: ; preds = %entry 185 %call11 = call float @Dummy(i32 -1) 186 %conv13 = fadd float %call11, 5.000000e-01 187 br label %return 188 189 sw.bb14: ; preds = %entry 190 %call15 = call float @Dummy(i32 -2) 191 %conv16 = fpext float %call15 to double 192 %add17 = fadd double %conv16, 0x3FD5555555555555 193 %conv18 = fptrunc double %add17 to float 194 br label %return 195 196 sw.bb19: ; preds = %entry 197 %call20 = call float @Dummy(i32 -3) 198 %conv23 = fadd float %call20, 2.500000e-01 199 br label %return 200 201 sw.bb24: ; preds = %entry 202 %call25 = call float @Dummy(i32 10) 203 %add26 = fadd float %call25, 0x7FF8000000000000 204 br label %return 205 206 sw.bb27: ; preds = %entry 207 %call28 = call float @Dummy(i32 -10) 208 %add29 = fadd float %call28, 0xFFF8000000000000 209 br label %return 210 211 sw.bb30: ; preds = %entry 212 %call31 = call float @Dummy(i32 100) 213 %add32 = fadd float %call31, 1.000000e+00 214 br label %return 215 216 sw.bb33: ; preds = %entry 217 %call34 = call float @Dummy(i32 101) 218 %add35 = fadd float %call34, 2.000000e+00 219 br label %return 220 221 sw.bb36: ; preds = %entry 222 %call37 = call float @Dummy(i32 102) 223 %add38 = fadd float %call37, 4.000000e+00 224 br label %return 225 226 sw.bb39: ; preds = %entry 227 %call40 = call float @Dummy(i32 103) 228 %add41 = fadd float %call40, 8.000000e+00 229 br label %return 230 231 sw.bb42: ; preds = %entry 232 %call43 = call float @Dummy(i32 -101) 233 %conv46 = fadd float %call43, 5.000000e-01 234 br label %return 235 236 sw.bb47: ; preds = %entry 237 %call48 = call float @Dummy(i32 -102) 238 %conv49 = fpext float %call48 to double 239 %add50 = fadd double %conv49, 0x3FD5555555555555 240 %conv51 = fptrunc double %add50 to float 241 br label %return 242 243 sw.bb52: ; preds = %entry 244 %call53 = call float @Dummy(i32 -103) 245 %conv56 = fadd float %call53, 2.500000e-01 246 br label %return 247 248 sw.bb57: ; preds = %entry 249 %call58 = call float @Dummy(i32 110) 250 %add59 = fadd float %call58, 0x7FF8000000000000 251 br label %return 252 253 sw.bb60: ; preds = %entry 254 %call61 = call float @Dummy(i32 -110) 255 %add62 = fadd float %call61, 0xFFF8000000000000 256 br label %return 257 258 return: ; preds = %entry, %sw.bb60, %sw.bb57, %sw.bb52, %sw.bb47, %sw.bb42, %sw.bb39, %sw.bb36, %sw.bb33, %sw.bb30, %sw.bb27, %sw.bb24, %sw.bb19, %sw.bb14, %sw.bb10, %sw.bb7, %sw.bb4, %sw.bb1, %sw.bb 259 %retval.0 = phi float [ %add62, %sw.bb60 ], [ %add59, %sw.bb57 ], [ %conv56, %sw.bb52 ], [ %conv51, %sw.bb47 ], [ %conv46, %sw.bb42 ], [ %add41, %sw.bb39 ], [ %add38, %sw.bb36 ], [ %add35, %sw.bb33 ], [ %add32, %sw.bb30 ], [ %add29, %sw.bb27 ], [ %add26, %sw.bb24 ], [ %conv23, %sw.bb19 ], [ %conv18, %sw.bb14 ], [ %conv13, %sw.bb10 ], [ %add9, %sw.bb7 ], [ %add6, %sw.bb4 ], [ %add3, %sw.bb1 ], [ %add, %sw.bb ], [ 0.000000e+00, %entry ] 260 ret float %retval.0 261 } 262 263 define internal double @FpLookup3(i32 %Arg) { 264 entry: 265 switch i32 %Arg, label %return [ 266 i32 0, label %sw.bb 267 i32 1, label %sw.bb1 268 i32 2, label %sw.bb5 269 i32 3, label %sw.bb9 270 i32 -1, label %sw.bb13 271 i32 -2, label %sw.bb17 272 i32 -3, label %sw.bb21 273 i32 10, label %sw.bb25 274 i32 -10, label %sw.bb29 275 i32 100, label %sw.bb33 276 i32 101, label %sw.bb37 277 i32 102, label %sw.bb41 278 i32 103, label %sw.bb45 279 i32 -101, label %sw.bb49 280 i32 -102, label %sw.bb53 281 i32 -103, label %sw.bb57 282 i32 110, label %sw.bb61 283 i32 -110, label %sw.bb65 284 ] 285 286 sw.bb: ; preds = %entry 287 %call = call float @Dummy(i32 0) 288 %add = fadd float %call, 1.000000e+00 289 %conv = fpext float %add to double 290 br label %return 291 292 sw.bb1: ; preds = %entry 293 %call2 = call float @Dummy(i32 1) 294 %add3 = fadd float %call2, 2.000000e+00 295 %conv4 = fpext float %add3 to double 296 br label %return 297 298 sw.bb5: ; preds = %entry 299 %call6 = call float @Dummy(i32 2) 300 %add7 = fadd float %call6, 4.000000e+00 301 %conv8 = fpext float %add7 to double 302 br label %return 303 304 sw.bb9: ; preds = %entry 305 %call10 = call float @Dummy(i32 3) 306 %add11 = fadd float %call10, 8.000000e+00 307 %conv12 = fpext float %add11 to double 308 br label %return 309 310 sw.bb13: ; preds = %entry 311 %call14 = call float @Dummy(i32 -1) 312 %conv15 = fpext float %call14 to double 313 %add16 = fadd double %conv15, 5.000000e-01 314 br label %return 315 316 sw.bb17: ; preds = %entry 317 %call18 = call float @Dummy(i32 -2) 318 %conv19 = fpext float %call18 to double 319 %add20 = fadd double %conv19, 0x3FD5555555555555 320 br label %return 321 322 sw.bb21: ; preds = %entry 323 %call22 = call float @Dummy(i32 -3) 324 %conv23 = fpext float %call22 to double 325 %add24 = fadd double %conv23, 2.500000e-01 326 br label %return 327 328 sw.bb25: ; preds = %entry 329 %call26 = call float @Dummy(i32 10) 330 %conv27 = fpext float %call26 to double 331 %add28 = fadd double %conv27, 0x7FF8000000000000 332 br label %return 333 334 sw.bb29: ; preds = %entry 335 %call30 = call float @Dummy(i32 -10) 336 %conv31 = fpext float %call30 to double 337 %add32 = fadd double %conv31, 0xFFF8000000000000 338 br label %return 339 340 sw.bb33: ; preds = %entry 341 %call34 = call float @Dummy(i32 100) 342 %add35 = fadd float %call34, 1.000000e+00 343 %conv36 = fpext float %add35 to double 344 br label %return 345 346 sw.bb37: ; preds = %entry 347 %call38 = call float @Dummy(i32 101) 348 %add39 = fadd float %call38, 2.000000e+00 349 %conv40 = fpext float %add39 to double 350 br label %return 351 352 sw.bb41: ; preds = %entry 353 %call42 = call float @Dummy(i32 102) 354 %add43 = fadd float %call42, 4.000000e+00 355 %conv44 = fpext float %add43 to double 356 br label %return 357 358 sw.bb45: ; preds = %entry 359 %call46 = call float @Dummy(i32 103) 360 %add47 = fadd float %call46, 8.000000e+00 361 %conv48 = fpext float %add47 to double 362 br label %return 363 364 sw.bb49: ; preds = %entry 365 %call50 = call float @Dummy(i32 -101) 366 %conv51 = fpext float %call50 to double 367 %add52 = fadd double %conv51, 5.000000e-01 368 br label %return 369 370 sw.bb53: ; preds = %entry 371 %call54 = call float @Dummy(i32 -102) 372 %conv55 = fpext float %call54 to double 373 %add56 = fadd double %conv55, 0x3FD5555555555555 374 br label %return 375 376 sw.bb57: ; preds = %entry 377 %call58 = call float @Dummy(i32 -103) 378 %conv59 = fpext float %call58 to double 379 %add60 = fadd double %conv59, 2.500000e-01 380 br label %return 381 382 sw.bb61: ; preds = %entry 383 %call62 = call float @Dummy(i32 110) 384 %conv63 = fpext float %call62 to double 385 %add64 = fadd double %conv63, 0x7FF8000000000000 386 br label %return 387 388 sw.bb65: ; preds = %entry 389 %call66 = call float @Dummy(i32 -110) 390 %conv67 = fpext float %call66 to double 391 %add68 = fadd double %conv67, 0xFFF8000000000000 392 br label %return 393 394 return: ; preds = %entry, %sw.bb65, %sw.bb61, %sw.bb57, %sw.bb53, %sw.bb49, %sw.bb45, %sw.bb41, %sw.bb37, %sw.bb33, %sw.bb29, %sw.bb25, %sw.bb21, %sw.bb17, %sw.bb13, %sw.bb9, %sw.bb5, %sw.bb1, %sw.bb 395 %retval.0 = phi double [ %add68, %sw.bb65 ], [ %add64, %sw.bb61 ], [ %add60, %sw.bb57 ], [ %add56, %sw.bb53 ], [ %add52, %sw.bb49 ], [ %conv48, %sw.bb45 ], [ %conv44, %sw.bb41 ], [ %conv40, %sw.bb37 ], [ %conv36, %sw.bb33 ], [ %add32, %sw.bb29 ], [ %add28, %sw.bb25 ], [ %add24, %sw.bb21 ], [ %add20, %sw.bb17 ], [ %add16, %sw.bb13 ], [ %conv12, %sw.bb9 ], [ %conv8, %sw.bb5 ], [ %conv4, %sw.bb1 ], [ %conv, %sw.bb ], [ 0.000000e+00, %entry ] 396 ret double %retval.0 397 } 398 399 define internal double @FpLookup4(i32 %Arg) { 400 entry: 401 switch i32 %Arg, label %return [ 402 i32 0, label %sw.bb 403 i32 1, label %sw.bb1 404 i32 2, label %sw.bb5 405 i32 3, label %sw.bb9 406 i32 -1, label %sw.bb13 407 i32 -2, label %sw.bb17 408 i32 -3, label %sw.bb21 409 i32 10, label %sw.bb25 410 i32 -10, label %sw.bb29 411 i32 100, label %sw.bb33 412 i32 101, label %sw.bb37 413 i32 102, label %sw.bb41 414 i32 103, label %sw.bb45 415 i32 -101, label %sw.bb49 416 i32 -102, label %sw.bb53 417 i32 -103, label %sw.bb57 418 i32 110, label %sw.bb61 419 i32 -110, label %sw.bb65 420 ] 421 422 sw.bb: ; preds = %entry 423 %call = call float @Dummy(i32 0) 424 %add = fadd float %call, 1.000000e+00 425 %conv = fpext float %add to double 426 br label %return 427 428 sw.bb1: ; preds = %entry 429 %call2 = call float @Dummy(i32 1) 430 %add3 = fadd float %call2, 2.000000e+00 431 %conv4 = fpext float %add3 to double 432 br label %return 433 434 sw.bb5: ; preds = %entry 435 %call6 = call float @Dummy(i32 2) 436 %add7 = fadd float %call6, 4.000000e+00 437 %conv8 = fpext float %add7 to double 438 br label %return 439 440 sw.bb9: ; preds = %entry 441 %call10 = call float @Dummy(i32 3) 442 %add11 = fadd float %call10, 8.000000e+00 443 %conv12 = fpext float %add11 to double 444 br label %return 445 446 sw.bb13: ; preds = %entry 447 %call14 = call float @Dummy(i32 -1) 448 %conv15 = fpext float %call14 to double 449 %add16 = fadd double %conv15, 5.000000e-01 450 br label %return 451 452 sw.bb17: ; preds = %entry 453 %call18 = call float @Dummy(i32 -2) 454 %conv19 = fpext float %call18 to double 455 %add20 = fadd double %conv19, 0x3FD5555555555555 456 br label %return 457 458 sw.bb21: ; preds = %entry 459 %call22 = call float @Dummy(i32 -3) 460 %conv23 = fpext float %call22 to double 461 %add24 = fadd double %conv23, 2.500000e-01 462 br label %return 463 464 sw.bb25: ; preds = %entry 465 %call26 = call float @Dummy(i32 10) 466 %conv27 = fpext float %call26 to double 467 %add28 = fadd double %conv27, 0x7FF8000000000000 468 br label %return 469 470 sw.bb29: ; preds = %entry 471 %call30 = call float @Dummy(i32 -10) 472 %conv31 = fpext float %call30 to double 473 %add32 = fadd double %conv31, 0xFFF8000000000000 474 br label %return 475 476 sw.bb33: ; preds = %entry 477 %call34 = call float @Dummy(i32 100) 478 %add35 = fadd float %call34, 1.000000e+00 479 %conv36 = fpext float %add35 to double 480 br label %return 481 482 sw.bb37: ; preds = %entry 483 %call38 = call float @Dummy(i32 101) 484 %add39 = fadd float %call38, 2.000000e+00 485 %conv40 = fpext float %add39 to double 486 br label %return 487 488 sw.bb41: ; preds = %entry 489 %call42 = call float @Dummy(i32 102) 490 %add43 = fadd float %call42, 4.000000e+00 491 %conv44 = fpext float %add43 to double 492 br label %return 493 494 sw.bb45: ; preds = %entry 495 %call46 = call float @Dummy(i32 103) 496 %add47 = fadd float %call46, 8.000000e+00 497 %conv48 = fpext float %add47 to double 498 br label %return 499 500 sw.bb49: ; preds = %entry 501 %call50 = call float @Dummy(i32 -101) 502 %conv51 = fpext float %call50 to double 503 %add52 = fadd double %conv51, 5.000000e-01 504 br label %return 505 506 sw.bb53: ; preds = %entry 507 %call54 = call float @Dummy(i32 -102) 508 %conv55 = fpext float %call54 to double 509 %add56 = fadd double %conv55, 0x3FD5555555555555 510 br label %return 511 512 sw.bb57: ; preds = %entry 513 %call58 = call float @Dummy(i32 -103) 514 %conv59 = fpext float %call58 to double 515 %add60 = fadd double %conv59, 2.500000e-01 516 br label %return 517 518 sw.bb61: ; preds = %entry 519 %call62 = call float @Dummy(i32 110) 520 %conv63 = fpext float %call62 to double 521 %add64 = fadd double %conv63, 0x7FF8000000000000 522 br label %return 523 524 sw.bb65: ; preds = %entry 525 %call66 = call float @Dummy(i32 -110) 526 %conv67 = fpext float %call66 to double 527 %add68 = fadd double %conv67, 0xFFF8000000000000 528 br label %return 529 530 return: ; preds = %entry, %sw.bb65, %sw.bb61, %sw.bb57, %sw.bb53, %sw.bb49, %sw.bb45, %sw.bb41, %sw.bb37, %sw.bb33, %sw.bb29, %sw.bb25, %sw.bb21, %sw.bb17, %sw.bb13, %sw.bb9, %sw.bb5, %sw.bb1, %sw.bb 531 %retval.0 = phi double [ %add68, %sw.bb65 ], [ %add64, %sw.bb61 ], [ %add60, %sw.bb57 ], [ %add56, %sw.bb53 ], [ %add52, %sw.bb49 ], [ %conv48, %sw.bb45 ], [ %conv44, %sw.bb41 ], [ %conv40, %sw.bb37 ], [ %conv36, %sw.bb33 ], [ %add32, %sw.bb29 ], [ %add28, %sw.bb25 ], [ %add24, %sw.bb21 ], [ %add20, %sw.bb17 ], [ %add16, %sw.bb13 ], [ %conv12, %sw.bb9 ], [ %conv8, %sw.bb5 ], [ %conv4, %sw.bb1 ], [ %conv, %sw.bb ], [ 0.000000e+00, %entry ] 532 ret double %retval.0 533 } 534 535 ; Make sure the constants in pools are shuffled. 536 537 ; Check for float pool 538 ; X86-LABEL: .rodata.cst4 539 ; X86: 00000041 0000c0ff 0000803f 00008040 540 ; X86: 0000c07f 0000003f 0000803e 00000040 541 542 ; Check for double pool 543 ; X86-LABEL: .rodata.cst8 544 ; X86: 00000000 0000f8ff 00000000 0000f87f 545 ; X86: 00000000 0000e03f 55555555 5555d53f 546 ; X86: 00000000 0000d03f 547 548 ; X86-LABEL: .text 549