Wouter van Oortmerssen | 8a9cb24 | 2018-08-27 15:45:51 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s |
| 2 | ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel | FileCheck %s |
Dan Gohman | a63e8eb | 2017-02-22 16:28:00 +0000 | [diff] [blame] | 3 | |
| 4 | ; Test that f16 is expanded. |
| 5 | |
| 6 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" |
Sam Clegg | a590800 | 2018-05-10 17:49:11 +0000 | [diff] [blame] | 7 | target triple = "wasm32-unknown-unknown" |
Dan Gohman | a63e8eb | 2017-02-22 16:28:00 +0000 | [diff] [blame] | 8 | |
Dan Gohman | 3a7532e | 2019-04-30 19:17:59 +0000 | [diff] [blame] | 9 | ; CHECK-LABEL: demote.f32: |
| 10 | ; CHECK-NEXT: .functype demote.f32 (f32) -> (f32){{$}} |
Thomas Lively | 6a87dda | 2019-01-08 06:25:55 +0000 | [diff] [blame] | 11 | ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}} |
Dan Gohman | 3a7532e | 2019-04-30 19:17:59 +0000 | [diff] [blame] | 12 | ; CHECK-NEXT: i32.call $push[[L1:[0-9]+]]=, __truncsfhf2, $pop[[L0]]{{$}} |
| 13 | ; CHECK-NEXT: f32.call $push[[L2:[0-9]+]]=, __extendhfsf2, $pop[[L1]]{{$}} |
Dan Gohman | a63e8eb | 2017-02-22 16:28:00 +0000 | [diff] [blame] | 14 | ; CHECK-NEXT: return $pop[[L2]]{{$}} |
Dan Gohman | 3a7532e | 2019-04-30 19:17:59 +0000 | [diff] [blame] | 15 | define half @demote.f32(float %f) { |
Dan Gohman | a63e8eb | 2017-02-22 16:28:00 +0000 | [diff] [blame] | 16 | %t = fptrunc float %f to half |
| 17 | ret half %t |
| 18 | } |
| 19 | |
Dan Gohman | 3a7532e | 2019-04-30 19:17:59 +0000 | [diff] [blame] | 20 | ; CHECK-LABEL: promote.f32: |
| 21 | ; CHECK-NEXT: .functype promote.f32 (f32) -> (f32){{$}} |
Thomas Lively | 6a87dda | 2019-01-08 06:25:55 +0000 | [diff] [blame] | 22 | ; CHECK-NEXT: local.get $push0=, 0{{$}} |
Dan Gohman | a63e8eb | 2017-02-22 16:28:00 +0000 | [diff] [blame] | 23 | ; CHECK-NEXT: return $pop0{{$}} |
Dan Gohman | 3a7532e | 2019-04-30 19:17:59 +0000 | [diff] [blame] | 24 | define float @promote.f32(half %f) { |
Dan Gohman | a63e8eb | 2017-02-22 16:28:00 +0000 | [diff] [blame] | 25 | %t = fpext half %f to float |
| 26 | ret float %t |
| 27 | } |
Dan Gohman | 3a7532e | 2019-04-30 19:17:59 +0000 | [diff] [blame] | 28 | |
| 29 | ; CHECK-LABEL: demote.f64: |
| 30 | ; CHECK-NEXT: .functype demote.f64 (f64) -> (f32){{$}} |
| 31 | ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}} |
| 32 | ; CHECK-NEXT: i32.call $push[[L1:[0-9]+]]=, __truncdfhf2, $pop[[L0]]{{$}} |
| 33 | ; CHECK-NEXT: f32.call $push[[L2:[0-9]+]]=, __extendhfsf2, $pop[[L1]]{{$}} |
| 34 | ; CHECK-NEXT: return $pop[[L2]]{{$}} |
| 35 | define half @demote.f64(double %f) { |
| 36 | %t = fptrunc double %f to half |
| 37 | ret half %t |
| 38 | } |
| 39 | |
| 40 | ; CHECK-LABEL: promote.f64: |
| 41 | ; CHECK-NEXT: .functype promote.f64 (f32) -> (f64){{$}} |
| 42 | ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}} |
| 43 | ; CHECK-NEXT: f64.promote_f32 $push[[L1:[0-9]+]]=, $pop[[L0]]{{$}} |
| 44 | ; CHECK-NEXT: return $pop[[L1]]{{$}} |
| 45 | define double @promote.f64(half %f) { |
| 46 | %t = fpext half %f to double |
| 47 | ret double %t |
| 48 | } |
| 49 | |
| 50 | ; CHECK-LABEL: demote.f128: |
| 51 | ; CHECK-NEXT: .functype demote.f128 (i64, i64) -> (f32){{$}} |
| 52 | ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}} |
| 53 | ; CHECK-NEXT: local.get $push[[L1:[0-9]+]]=, 1{{$}} |
| 54 | ; CHECK-NEXT: i32.call $push[[L2:[0-9]+]]=, __trunctfhf2, $pop[[L0]], $pop[[L1]]{{$}} |
| 55 | ; CHECK-NEXT: f32.call $push[[L3:[0-9]+]]=, __extendhfsf2, $pop[[L2]]{{$}} |
| 56 | ; CHECK-NEXT: return $pop[[L3]]{{$}} |
| 57 | define half @demote.f128(fp128 %f) { |
| 58 | %t = fptrunc fp128 %f to half |
| 59 | ret half %t |
| 60 | } |
| 61 | |
| 62 | ; CHECK-LABEL: promote.f128: |
| 63 | ; CHECK-NEXT: .functype promote.f128 (i32, f32) -> (){{$}} |
| 64 | ; CHECK: call __extendsftf2 |
| 65 | ; CHECK: i64.store |
| 66 | ; CHECK: i64.store |
| 67 | define fp128 @promote.f128(half %f) { |
| 68 | %t = fpext half %f to fp128 |
| 69 | ret fp128 %t |
| 70 | } |