llvm.org GIT mirror llvm / b41b1d4
NVPTX: support fpext/fptrunc to and from f16. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213377 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 6 years ago
2 changed file(s) with 43 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
202202 setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom);
203203
204204 // Turn FP extload into load/fextend
205 setLoadExtAction(ISD::EXTLOAD, MVT::f16, Expand);
205206 setLoadExtAction(ISD::EXTLOAD, MVT::f32, Expand);
206207 // Turn FP truncstore into trunc + store.
208 setTruncStoreAction(MVT::f32, MVT::f16, Expand);
209 setTruncStoreAction(MVT::f64, MVT::f16, Expand);
207210 setTruncStoreAction(MVT::f64, MVT::f32, Expand);
208211
209212 // PTX does not support load / store predicate registers
2727 store half %val_fp, half addrspace(1)* %out
2828 ret void
2929 }
30
31 define void @test_extend32(half addrspace(1)* %in, float addrspace(1)* %out) {
32 ; CHECK-LABEL: @test_extend32
33 ; CHECK: cvt.f32.f16
34
35 %val16 = load half addrspace(1)* %in
36 %val32 = fpext half %val16 to float
37 store float %val32, float addrspace(1)* %out
38 ret void
39 }
40
41 define void @test_extend64(half addrspace(1)* %in, double addrspace(1)* %out) {
42 ; CHECK-LABEL: @test_extend64
43 ; CHECK: cvt.f64.f16
44
45 %val16 = load half addrspace(1)* %in
46 %val64 = fpext half %val16 to double
47 store double %val64, double addrspace(1)* %out
48 ret void
49 }
50
51 define void @test_trunc32(float addrspace(1)* %in, half addrspace(1)* %out) {
52 ; CHECK-LABEL: test_trunc32
53 ; CHECK: cvt.rn.f16.f32
54
55 %val32 = load float addrspace(1)* %in
56 %val16 = fptrunc float %val32 to half
57 store half %val16, half addrspace(1)* %out
58 ret void
59 }
60
61 define void @test_trunc64(double addrspace(1)* %in, half addrspace(1)* %out) {
62 ; CHECK-LABEL: @test_trunc64
63 ; CHECK: cvt.rn.f16.f64
64
65 %val32 = load double addrspace(1)* %in
66 %val16 = fptrunc double %val32 to half
67 store half %val16, half addrspace(1)* %out
68 ret void
69 }