|
1 | | -; RUN: llc < %s | FileCheck %s --check-prefix=CHECK --check-prefix=SAFE |
2 | | -; RUN: llc < %s -enable-unsafe-fp-math | FileCheck %s --check-prefix=CHECK --check-prefix=UNSAFE |
| 1 | +; RUN: llc < %s | FileCheck %s |
3 | 2 |
|
4 | 3 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
5 | 4 | target triple = "x86_64--" |
6 | 5 |
|
| 6 | +; CHECK-LABEL: double_rounding_safe: |
| 7 | +; CHECK: callq __trunctfdf2 |
| 8 | +; CHECK-NEXT: cvtsd2ss %xmm0 |
| 9 | +define void @double_rounding_safe(ptr %x, ptr %f) { |
| 10 | +entry: |
| 11 | + %x.fp128 = load fp128, ptr %x, align 16 |
| 12 | + %x.double = fptrunc fp128 %x.fp128 to double |
| 13 | + %x.float = fptrunc double %x.double to float |
| 14 | + store float %x.float, ptr %f, align 4 |
| 15 | + ret void |
| 16 | +} |
| 17 | + |
| 18 | +; CHECK-LABEL: double_rounding_contract_fst: |
| 19 | +; CHECK: callq __trunctfdf2 |
| 20 | +; CHECK-NEXT: cvtsd2ss %xmm0 |
| 21 | +define void @double_rounding_contract_fst(ptr %x, ptr %f) { |
| 22 | +entry: |
| 23 | + %x.fp128 = load fp128, ptr %x, align 16 |
| 24 | + %x.double = fptrunc contract fp128 %x.fp128 to double |
| 25 | + %x.float = fptrunc double %x.double to float |
| 26 | + store float %x.float, ptr %f, align 4 |
| 27 | + ret void |
| 28 | +} |
| 29 | + |
| 30 | +; CHECK-LABEL: double_rounding_contract_snd: |
| 31 | +; CHECK: callq __trunctfdf2 |
| 32 | +; CHECK-NEXT: cvtsd2ss %xmm0 |
| 33 | +define void @double_rounding_contract_snd(ptr %x, ptr %f) { |
| 34 | +entry: |
| 35 | + %x.fp128 = load fp128, ptr %x, align 16 |
| 36 | + %x.double = fptrunc fp128 %x.fp128 to double |
| 37 | + %x.float = fptrunc contract double %x.double to float |
| 38 | + store float %x.float, ptr %f, align 4 |
| 39 | + ret void |
| 40 | +} |
| 41 | + |
7 | 42 | ; CHECK-LABEL: double_rounding: |
8 | | -; SAFE: callq __trunctfdf2 |
9 | | -; SAFE-NEXT: cvtsd2ss %xmm0 |
10 | | -; UNSAFE: callq __trunctfsf2 |
11 | | -; UNSAFE-NOT: cvt |
| 43 | +; CHECK: callq __trunctfsf2 |
| 44 | +; CHECK-NOT: cvt |
12 | 45 | define void @double_rounding(ptr %x, ptr %f) { |
13 | 46 | entry: |
14 | | - %0 = load fp128, ptr %x, align 16 |
15 | | - %1 = fptrunc fp128 %0 to double |
16 | | - %2 = fptrunc double %1 to float |
17 | | - store float %2, ptr %f, align 4 |
| 47 | + %x.fp128 = load fp128, ptr %x, align 16 |
| 48 | + %x.double = fptrunc contract fp128 %x.fp128 to double |
| 49 | + %x.float = fptrunc contract double %x.double to float |
| 50 | + store float %x.float, ptr %f, align 4 |
18 | 51 | ret void |
19 | 52 | } |
20 | 53 |
|
|
0 commit comments