blob: 532e3e626b2c63052907a345ba7f76d510b0ed5c [file] [log] [blame]
Thomas Livelyc9498572018-09-26 00:34:36 +00001; RUN: llc < %s -asm-verbose=false -wasm-keep-registers -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext | FileCheck %s --check-prefixes CHECK,SIMD128
2; RUN: llc < %s -asm-verbose=false -wasm-keep-registers -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+simd128,+sign-ext | FileCheck %s --check-prefixes CHECK,SIMD128-VM
3; RUN: llc < %s -asm-verbose=false -wasm-keep-registers -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=-simd128,+sign-ext | FileCheck %s --check-prefixes CHECK,NO-SIMD128
4
5; Test that vector float-to-int and int-to-float instructions lower correctly
6
7target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8target triple = "wasm32-unknown-unknown"
9
10; CHECK-LABEL: convert_s_v4f32:
11; NO-SIMD128-NOT: i32x4
12; SIMD128-NEXT: .param v128{{$}}
13; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000014; SIMD128-NEXT: f32x4.convert_s/i32x4 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000015; SIMD128-NEXT: return $pop[[R]]
16define <4 x float> @convert_s_v4f32(<4 x i32> %x) {
17 %a = sitofp <4 x i32> %x to <4 x float>
18 ret <4 x float> %a
19}
20
21; CHECK-LABEL: convert_u_v4f32:
22; NO-SIMD128-NOT: i32x4
23; SIMD128-NEXT: .param v128{{$}}
24; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000025; SIMD128-NEXT: f32x4.convert_u/i32x4 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000026; SIMD128-NEXT: return $pop[[R]]
27define <4 x float> @convert_u_v4f32(<4 x i32> %x) {
28 %a = uitofp <4 x i32> %x to <4 x float>
29 ret <4 x float> %a
30}
31
32; CHECK-LABEL: convert_s_v2f64:
33; NO-SIMD128-NOT: i64x2
Thomas Lively6f778112018-10-02 01:52:21 +000034; SIMD128-VM-NOT: f64x2.convert_s/i64x2
Thomas Livelyc9498572018-09-26 00:34:36 +000035; SIMD128-NEXT: .param v128{{$}}
36; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000037; SIMD128-NEXT: f64x2.convert_s/i64x2 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000038; SIMD128-NEXT: return $pop[[R]]
39define <2 x double> @convert_s_v2f64(<2 x i64> %x) {
40 %a = sitofp <2 x i64> %x to <2 x double>
41 ret <2 x double> %a
42}
43
44; CHECK-LABEL: convert_u_v2f64:
45; NO-SIMD128-NOT: i64x2
Thomas Lively6f778112018-10-02 01:52:21 +000046; SIMD128-VM-NOT: f64x2.convert_u/i64x2
Thomas Livelyc9498572018-09-26 00:34:36 +000047; SIMD128-NEXT: .param v128{{$}}
48; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000049; SIMD128-NEXT: f64x2.convert_u/i64x2 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000050; SIMD128-NEXT: return $pop[[R]]
51define <2 x double> @convert_u_v2f64(<2 x i64> %x) {
52 %a = uitofp <2 x i64> %x to <2 x double>
53 ret <2 x double> %a
54}
55
Thomas Lively6f778112018-10-02 01:52:21 +000056; CHECK-LABEL: trunc_sat_s_v4i32:
Thomas Livelyc9498572018-09-26 00:34:36 +000057; NO-SIMD128-NOT: f32x4
58; SIMD128-NEXT: .param v128{{$}}
59; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000060; SIMD128-NEXT: i32x4.trunc_sat_s/f32x4 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000061; SIMD128-NEXT: return $pop[[R]]
Thomas Lively6f778112018-10-02 01:52:21 +000062define <4 x i32> @trunc_sat_s_v4i32(<4 x float> %x) {
Thomas Livelyc9498572018-09-26 00:34:36 +000063 %a = fptosi <4 x float> %x to <4 x i32>
64 ret <4 x i32> %a
65}
66
Thomas Lively6f778112018-10-02 01:52:21 +000067; CHECK-LABEL: trunc_sat_u_v4i32:
Thomas Livelyc9498572018-09-26 00:34:36 +000068; NO-SIMD128-NOT: f32x4
69; SIMD128-NEXT: .param v128{{$}}
70; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000071; SIMD128-NEXT: i32x4.trunc_sat_u/f32x4 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000072; SIMD128-NEXT: return $pop[[R]]
Thomas Lively6f778112018-10-02 01:52:21 +000073define <4 x i32> @trunc_sat_u_v4i32(<4 x float> %x) {
Thomas Livelyc9498572018-09-26 00:34:36 +000074 %a = fptoui <4 x float> %x to <4 x i32>
75 ret <4 x i32> %a
76}
77
Thomas Lively6f778112018-10-02 01:52:21 +000078; CHECK-LABEL: trunc_sat_s_v2i64:
Thomas Livelyc9498572018-09-26 00:34:36 +000079; NO-SIMD128-NOT: f64x2
Thomas Lively6f778112018-10-02 01:52:21 +000080; SIMD128-VM-NOT: i64x2.trunc_sat_s/f64x2
Thomas Livelyc9498572018-09-26 00:34:36 +000081; SIMD128-NEXT: .param v128{{$}}
82; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000083; SIMD128-NEXT: i64x2.trunc_sat_s/f64x2 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000084; SIMD128-NEXT: return $pop[[R]]
Thomas Lively6f778112018-10-02 01:52:21 +000085define <2 x i64> @trunc_sat_s_v2i64(<2 x double> %x) {
Thomas Livelyc9498572018-09-26 00:34:36 +000086 %a = fptosi <2 x double> %x to <2 x i64>
87 ret <2 x i64> %a
88}
89
Thomas Lively6f778112018-10-02 01:52:21 +000090; CHECK-LABEL: trunc_sat_u_v2i64:
Thomas Livelyc9498572018-09-26 00:34:36 +000091; NO-SIMD128-NOT: f64x2
Thomas Lively6f778112018-10-02 01:52:21 +000092; SIMD128-VM-NOT: i64x2.trunc_sat_u/f64x2
Thomas Livelyc9498572018-09-26 00:34:36 +000093; SIMD128-NEXT: .param v128{{$}}
94; SIMD128-NEXT: .result v128{{$}}
Thomas Lively6f778112018-10-02 01:52:21 +000095; SIMD128-NEXT: i64x2.trunc_sat_u/f64x2 $push[[R:[0-9]+]]=, $0
Thomas Livelyc9498572018-09-26 00:34:36 +000096; SIMD128-NEXT: return $pop[[R]]
Thomas Lively6f778112018-10-02 01:52:21 +000097define <2 x i64> @trunc_sat_u_v2i64(<2 x double> %x) {
Thomas Livelyc9498572018-09-26 00:34:36 +000098 %a = fptoui <2 x double> %x to <2 x i64>
99 ret <2 x i64> %a
100}