| OLD | NEW |
| 1 ; This is a smoke test for floating-point constant pooling. It tests | 1 ; This is a smoke test for reordering pooled constants. |
| 2 ; pooling of various float and double constants (including positive | 2 ; This option is only implemented for target X8632 for now. |
| 3 ; and negative NaN) within functions and across functions. Note that | |
| 4 ; in LLVM bitcode, hex constants are used for an FP constant whenever | |
| 5 ; the constant "cannot be represented as a decimal floating point | |
| 6 ; number in a reasonable number of digits". See | |
| 7 ; http://llvm.org/docs/LangRef.html#simple-constants . | |
| 8 | 3 |
| 9 ; RUN: %p2i --assemble --disassemble --filetype=obj --dis-flags=-s \ | 4 ; RUN: %p2i --assemble --disassemble --filetype=obj --dis-flags=-s \ |
| 10 ; RUN: -i %s --args -O2 --verbose none | FileCheck %s | 5 ; RUN: --target x8632 -i %s --args -sz-seed=1 -O2 -reorder-pooled-constants \ |
| 6 ; RUN: | FileCheck %s --check-prefix=X86O2 |
| 7 |
| 11 ; RUN: %p2i --assemble --disassemble --filetype=obj --dis-flags=-s \ | 8 ; RUN: %p2i --assemble --disassemble --filetype=obj --dis-flags=-s \ |
| 12 ; RUN: -i %s --args -Om1 --verbose none | FileCheck %s | 9 ; RUN: --target x8632 -i %s --args -sz-seed=1 -Om1 -reorder-pooled-constants \ |
| 13 | 10 ; RUN: | FileCheck %s --check-prefix=X86OM1 |
| 14 ; RUN: %if --need allow_dump --command %p2i --assemble --disassemble \ | |
| 15 ; RUN: --dis-flags=-s -i %s --args -O2 --verbose none \ | |
| 16 ; RUN: | %if --need allow_dump --command FileCheck %s | |
| 17 ; RUN: %if --need allow_dump --command %p2i --assemble --disassemble \ | |
| 18 ; RUN: --dis-flags=-s -i %s --args -Om1 --verbose none \ | |
| 19 ; RUN: | %if --need allow_dump --command FileCheck %s | |
| 20 | 11 |
| 21 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 12 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 22 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 13 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 23 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 | 14 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 |
| 24 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 | 15 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 |
| 25 | 16 |
| 26 define internal float @FpLookup1(i32 %Arg) { | 17 define internal float @FpLookup1(i32 %Arg) { |
| 27 entry: | 18 entry: |
| 28 switch i32 %Arg, label %return [ | 19 switch i32 %Arg, label %return [ |
| 29 i32 0, label %sw.bb | 20 i32 0, label %sw.bb |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 %call66 = call float @Dummy(i32 -110) | 525 %call66 = call float @Dummy(i32 -110) |
| 535 %conv67 = fpext float %call66 to double | 526 %conv67 = fpext float %call66 to double |
| 536 %add68 = fadd double %conv67, 0xFFF8000000000000 | 527 %add68 = fadd double %conv67, 0xFFF8000000000000 |
| 537 br label %return | 528 br label %return |
| 538 | 529 |
| 539 return: ; preds = %entry, %sw.bb65, %s
w.bb61, %sw.bb57, %sw.bb53, %sw.bb49, %sw.bb45, %sw.bb41, %sw.bb37, %sw.bb33, %s
w.bb29, %sw.bb25, %sw.bb21, %sw.bb17, %sw.bb13, %sw.bb9, %sw.bb5, %sw.bb1, %sw.b
b | 530 return: ; preds = %entry, %sw.bb65, %s
w.bb61, %sw.bb57, %sw.bb53, %sw.bb49, %sw.bb45, %sw.bb41, %sw.bb37, %sw.bb33, %s
w.bb29, %sw.bb25, %sw.bb21, %sw.bb17, %sw.bb13, %sw.bb9, %sw.bb5, %sw.bb1, %sw.b
b |
| 540 %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 ], [ %ad
d16, %sw.bb13 ], [ %conv12, %sw.bb9 ], [ %conv8, %sw.bb5 ], [ %conv4, %sw.bb1 ],
[ %conv, %sw.bb ], [ 0.000000e+00, %entry ] | 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 ], [ %ad
d16, %sw.bb13 ], [ %conv12, %sw.bb9 ], [ %conv8, %sw.bb5 ], [ %conv4, %sw.bb1 ],
[ %conv, %sw.bb ], [ 0.000000e+00, %entry ] |
| 541 ret double %retval.0 | 532 ret double %retval.0 |
| 542 } | 533 } |
| 543 | 534 |
| 544 ; The FP constant pool entries for each type are dumped in some | 535 ; Make sure the constants in pools are shuffled. |
| 545 ; implementation-dependent order. So for the purposes of lit, we just | 536 ; TODO(qining, stichnot): Unify the checkers for Om1 and O2 optimization levels. |
| 546 ; pick one value for each type, and make sure it appears exactly once. | 537 ; Om1 and O2 result into different sizes of i32 constant pools. |
| 538 ; Because the shuffling routine of constant pools is applied to integer |
| 539 ; constant pools first, the random number used for shuffling float and double |
| 540 ; constant pools will be different for Om1 and O2, so is the order of the pooled |
| 541 ; float and double constants. The source of this difference may includes: stack |
| 542 ; frame size, strength reduction, etc. |
| 547 | 543 |
| 548 ; Check for float 0.5 | 544 ; Check for float pool |
| 549 ; CHECK-LABEL: .rodata.cst4 | 545 ; X86O2-LABEL: .rodata.cst4 |
| 550 ; CHECK: 0000003f | 546 ; X86O2: 00000040 0000c0ff 00000041 00000000 |
| 551 ; CHECK-NOT: 0000003f | 547 ; X86O2: 0000003f 0000803f 00008040 0000c07f |
| 548 ; X86O2: 0000803e |
| 552 | 549 |
| 553 ; Check for double 0.5 | 550 ; Check for double pool |
| 554 ; CHECK-LABEL: .rodata.cst8 | 551 ; X86O2-LABEL: .rodata.cst8 |
| 555 ; CHECK: 00000000 0000e03f | 552 ; X86O2: 55555555 5555d53f 00000000 0000f8ff |
| 556 ; CHECK-NOT: 00000000 0000e03f | 553 ; X86O2: 00000000 0000f87f 00000000 0000e03f |
| 557 ; CHECK-LABEL: .text | 554 ; X86O2: 00000000 0000d03f 00000000 00000000 |
| 555 |
| 556 ; X86O2-LABEL: .text |
| 557 |
| 558 ; Check for float pool |
| 559 ; X86OM1-LABEL: .rodata.cst4 |
| 560 ; X86OM1: 0000803f 0000003f 00000040 0000c0ff |
| 561 ; X86OM1: 00000000 00008040 0000c07f 0000803e |
| 562 ; X86OM1: 00000041 |
| 563 |
| 564 ; Check for double pool |
| 565 ; X86OM1-LABEL: .rodata.cst8 |
| 566 ; X86OM1: 00000000 0000e03f 00000000 0000f87f |
| 567 ; X86OM1: 00000000 0000f8ff 00000000 0000d03f |
| 568 ; X86OM1: 00000000 00000000 55555555 5555d53f |
| 569 |
| 570 ; X86OM1-LABEL: .text |
| OLD | NEW |