mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-04 19:38:22 +00:00
b080ff471d
Officially, we don't acknowledge non-default configurations of MXCSR, as getting there would require usage of the FENV_ACCESS pragma (at least insofar as rounding mode is concerned). We don't support the pragma, so we can assume that the default rounding mode - round to nearest, ties to even - is always used. However, it's inconsistent with the rest of the instruction set, where MXCSR is always effective (unless otherwise specified). Also, it's an unnecessary obstacle to the few brave souls that use fenv.h with LLVM. Avoid the hard-coded rounding mode for fp_to_f16; use MXCSR instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259448 91177308-0d34-0410-b5e6-96231b3b80d8
53 lines
1.5 KiB
LLVM
53 lines
1.5 KiB
LLVM
; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s --check-prefix=ALL --check-prefix=F16C
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX
|
|
|
|
define zeroext i16 @test1_fast(double %d) #0 {
|
|
; ALL-LABEL: test1_fast:
|
|
; F16C-NOT: callq {{_+}}truncdfhf2
|
|
; F16C: vcvtsd2ss %xmm0, %xmm0, %xmm0
|
|
; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
|
|
; AVX: callq {{_+}}truncdfhf2
|
|
; ALL: ret
|
|
entry:
|
|
%0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
|
|
ret i16 %0
|
|
}
|
|
|
|
define zeroext i16 @test2_fast(x86_fp80 %d) #0 {
|
|
; ALL-LABEL: test2_fast:
|
|
; F16C-NOT: callq {{_+}}truncxfhf2
|
|
; F16C: fldt
|
|
; F16C-NEXT: fstps
|
|
; F16C-NEXT: vmovss
|
|
; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
|
|
; AVX: callq {{_+}}truncxfhf2
|
|
; ALL: ret
|
|
entry:
|
|
%0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
|
|
ret i16 %0
|
|
}
|
|
|
|
define zeroext i16 @test1(double %d) #1 {
|
|
; ALL-LABEL: test1:
|
|
; ALL: callq {{_+}}truncdfhf2
|
|
; ALL: ret
|
|
entry:
|
|
%0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
|
|
ret i16 %0
|
|
}
|
|
|
|
define zeroext i16 @test2(x86_fp80 %d) #1 {
|
|
; ALL-LABEL: test2:
|
|
; ALL: callq {{_+}}truncxfhf2
|
|
; ALL: ret
|
|
entry:
|
|
%0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
|
|
ret i16 %0
|
|
}
|
|
|
|
declare i16 @llvm.convert.to.fp16.f64(double)
|
|
declare i16 @llvm.convert.to.fp16.f80(x86_fp80)
|
|
|
|
attributes #0 = { nounwind readnone uwtable "unsafe-fp-math"="true" "use-soft-float"="false" }
|
|
attributes #1 = { nounwind readnone uwtable "unsafe-fp-math"="false" "use-soft-float"="false" }
|