blob: b25f16c499a80fab326a322d7060823f08f91622 [file] [log] [blame]
Dan Gohman7d7409e2017-02-28 23:37:04 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s
2; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -fast-isel -fast-isel-abort=1 | FileCheck %s
Derek Schuff6b5c6da2015-11-03 22:40:40 +00003
4; Test that wasm select instruction is selected from LLVM select instruction.
5
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00006target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman7d7409e2017-02-28 23:37:04 +00007target triple = "wasm32-unknown-unknown-wasm"
Derek Schuff6b5c6da2015-11-03 22:40:40 +00008
Dan Gohmand9b42182015-11-25 22:13:48 +00009; CHECK-LABEL: select_i32_bool:
10; CHECK-NEXT: .param i32, i32, i32{{$}}
11; CHECK-NEXT: .result i32{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000012; CHECK-NEXT: i32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000013; CHECK-NEXT: return $pop0{{$}}
14define i32 @select_i32_bool(i1 zeroext %a, i32 %b, i32 %c) {
15 %cond = select i1 %a, i32 %b, i32 %c
16 ret i32 %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +000017}
18
Dan Gohmand9b42182015-11-25 22:13:48 +000019; CHECK-LABEL: select_i32_eq:
20; CHECK-NEXT: .param i32, i32, i32{{$}}
21; CHECK-NEXT: .result i32{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000022; CHECK-NEXT: i32.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000023; CHECK-NEXT: return $pop0{{$}}
24define i32 @select_i32_eq(i32 %a, i32 %b, i32 %c) {
25 %cmp = icmp eq i32 %a, 0
26 %cond = select i1 %cmp, i32 %b, i32 %c
27 ret i32 %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +000028}
29
Dan Gohmand9b42182015-11-25 22:13:48 +000030; CHECK-LABEL: select_i32_ne:
31; CHECK-NEXT: .param i32, i32, i32{{$}}
32; CHECK-NEXT: .result i32{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000033; CHECK-NEXT: i32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000034; CHECK-NEXT: return $pop0{{$}}
35define i32 @select_i32_ne(i32 %a, i32 %b, i32 %c) {
36 %cmp = icmp ne i32 %a, 0
37 %cond = select i1 %cmp, i32 %b, i32 %c
38 ret i32 %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +000039}
40
Dan Gohmand9b42182015-11-25 22:13:48 +000041; CHECK-LABEL: select_i64_bool:
42; CHECK-NEXT: .param i32, i64, i64{{$}}
43; CHECK-NEXT: .result i64{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000044; CHECK-NEXT: i64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000045; CHECK-NEXT: return $pop0{{$}}
46define i64 @select_i64_bool(i1 zeroext %a, i64 %b, i64 %c) {
47 %cond = select i1 %a, i64 %b, i64 %c
48 ret i64 %cond
49}
50
51; CHECK-LABEL: select_i64_eq:
52; CHECK-NEXT: .param i32, i64, i64{{$}}
53; CHECK-NEXT: .result i64{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000054; CHECK-NEXT: i64.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000055; CHECK-NEXT: return $pop0{{$}}
56define i64 @select_i64_eq(i32 %a, i64 %b, i64 %c) {
57 %cmp = icmp eq i32 %a, 0
58 %cond = select i1 %cmp, i64 %b, i64 %c
59 ret i64 %cond
60}
61
62; CHECK-LABEL: select_i64_ne:
63; CHECK-NEXT: .param i32, i64, i64{{$}}
64; CHECK-NEXT: .result i64{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000065; CHECK-NEXT: i64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000066; CHECK-NEXT: return $pop0{{$}}
67define i64 @select_i64_ne(i32 %a, i64 %b, i64 %c) {
68 %cmp = icmp ne i32 %a, 0
69 %cond = select i1 %cmp, i64 %b, i64 %c
70 ret i64 %cond
71}
72
73; CHECK-LABEL: select_f32_bool:
74; CHECK-NEXT: .param i32, f32, f32{{$}}
75; CHECK-NEXT: .result f32{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000076; CHECK-NEXT: f32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000077; CHECK-NEXT: return $pop0{{$}}
78define float @select_f32_bool(i1 zeroext %a, float %b, float %c) {
79 %cond = select i1 %a, float %b, float %c
80 ret float %cond
81}
82
83; CHECK-LABEL: select_f32_eq:
84; CHECK-NEXT: .param i32, f32, f32{{$}}
85; CHECK-NEXT: .result f32{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000086; CHECK-NEXT: f32.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000087; CHECK-NEXT: return $pop0{{$}}
88define float @select_f32_eq(i32 %a, float %b, float %c) {
89 %cmp = icmp eq i32 %a, 0
90 %cond = select i1 %cmp, float %b, float %c
91 ret float %cond
92}
93
94; CHECK-LABEL: select_f32_ne:
95; CHECK-NEXT: .param i32, f32, f32{{$}}
96; CHECK-NEXT: .result f32{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000097; CHECK-NEXT: f32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000098; CHECK-NEXT: return $pop0{{$}}
99define float @select_f32_ne(i32 %a, float %b, float %c) {
100 %cmp = icmp ne i32 %a, 0
101 %cond = select i1 %cmp, float %b, float %c
102 ret float %cond
103}
104
105; CHECK-LABEL: select_f64_bool:
106; CHECK-NEXT: .param i32, f64, f64{{$}}
107; CHECK-NEXT: .result f64{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000108; CHECK-NEXT: f64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000109; CHECK-NEXT: return $pop0{{$}}
110define double @select_f64_bool(i1 zeroext %a, double %b, double %c) {
111 %cond = select i1 %a, double %b, double %c
112 ret double %cond
113}
114
115; CHECK-LABEL: select_f64_eq:
116; CHECK-NEXT: .param i32, f64, f64{{$}}
117; CHECK-NEXT: .result f64{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000118; CHECK-NEXT: f64.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000119; CHECK-NEXT: return $pop0{{$}}
120define double @select_f64_eq(i32 %a, double %b, double %c) {
121 %cmp = icmp eq i32 %a, 0
122 %cond = select i1 %cmp, double %b, double %c
123 ret double %cond
124}
125
126; CHECK-LABEL: select_f64_ne:
127; CHECK-NEXT: .param i32, f64, f64{{$}}
128; CHECK-NEXT: .result f64{{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000129; CHECK-NEXT: f64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000130; CHECK-NEXT: return $pop0{{$}}
131define double @select_f64_ne(i32 %a, double %b, double %c) {
132 %cmp = icmp ne i32 %a, 0
133 %cond = select i1 %cmp, double %b, double %c
134 ret double %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +0000135}