xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/fp-double-rounding.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s --check-prefix=CHECK --check-prefix=SAFE
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -enable-unsafe-fp-math | FileCheck %s --check-prefix=CHECK --check-prefix=UNSAFE
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64--"
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: double_rounding:
8*9880d681SAndroid Build Coastguard Worker; SAFE: callq __trunctfdf2
9*9880d681SAndroid Build Coastguard Worker; SAFE-NEXT: cvtsd2ss %xmm0
10*9880d681SAndroid Build Coastguard Worker; UNSAFE: callq __trunctfsf2
11*9880d681SAndroid Build Coastguard Worker; UNSAFE-NOT: cvt
12*9880d681SAndroid Build Coastguard Workerdefine void @double_rounding(fp128* %x, float* %f) {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker  %0 = load fp128, fp128* %x, align 16
15*9880d681SAndroid Build Coastguard Worker  %1 = fptrunc fp128 %0 to double
16*9880d681SAndroid Build Coastguard Worker  %2 = fptrunc double %1 to float
17*9880d681SAndroid Build Coastguard Worker  store float %2, float* %f, align 4
18*9880d681SAndroid Build Coastguard Worker  ret void
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: double_rounding_precise_first:
22*9880d681SAndroid Build Coastguard Worker; CHECK: fstps (%
23*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: fstpl
24*9880d681SAndroid Build Coastguard Workerdefine void @double_rounding_precise_first(float* %f) {
25*9880d681SAndroid Build Coastguard Workerentry:
26*9880d681SAndroid Build Coastguard Worker  ; Hack, to generate a precise FP_ROUND to double
27*9880d681SAndroid Build Coastguard Worker  %precise = call double asm sideeffect "fld %st(0)", "={st(0)}"()
28*9880d681SAndroid Build Coastguard Worker  %0 = fptrunc double %precise to float
29*9880d681SAndroid Build Coastguard Worker  store float %0, float* %f, align 4
30*9880d681SAndroid Build Coastguard Worker  ret void
31*9880d681SAndroid Build Coastguard Worker}
32