llvm.org GIT mirror llvm / 61ce026
[WebAssembly] Configure codegen to legalize f16 values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295850 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 3 years ago
2 changed file(s) with 33 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
9494 // Support minnan and maxnan, which otherwise default to expand.
9595 setOperationAction(ISD::FMINNAN, T, Legal);
9696 setOperationAction(ISD::FMAXNAN, T, Legal);
97 // WebAssembly currently has no builtin f16 support.
98 setOperationAction(ISD::FP16_TO_FP, T, Expand);
99 setOperationAction(ISD::FP_TO_FP16, T, Expand);
100 setLoadExtAction(ISD::EXTLOAD, T, MVT::f16, Expand);
101 setTruncStoreAction(T, MVT::f16, Expand);
97102 }
98103
99104 for (auto T : {MVT::i32, MVT::i64}) {
0 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
1
2 ; Test that f16 is expanded.
3
4 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
5 target triple = "wasm32-unknown-unknown-wasm"
6
7 ; CHECK-LABEL: demote:
8 ; CHECK-NEXT: .param f32{{$}}
9 ; CHECK-NEXT: .result f32{{$}}
10 ; CHECK-NEXT: get_local $push[[L0:[0-9]+]]=, 0{{$}}
11 ; CHECK-NEXT: i32.call $push[[L1:[0-9]+]]=, __gnu_f2h_ieee@FUNCTION, $pop[[L0]]{{$}}
12 ; CHECK-NEXT: f32.call $push[[L2:[0-9]+]]=, __gnu_h2f_ieee@FUNCTION, $pop[[L1]]{{$}}
13 ; CHECK-NEXT: return $pop[[L2]]{{$}}
14 define half @demote(float %f) {
15 %t = fptrunc float %f to half
16 ret half %t
17 }
18
19 ; CHECK-LABEL: promote:
20 ; CHECK-NEXT: .param f32{{$}}
21 ; CHECK-NEXT: .result f32{{$}}
22 ; CHECK-NEXT: get_local $push0=, 0{{$}}
23 ; CHECK-NEXT: return $pop0{{$}}
24 define float @promote(half %f) {
25 %t = fpext half %f to float
26 ret float %t
27 }