blob: daa934f448448edd1bce96e42cf3fa1352921d41 [file] [log] [blame]
Thomas Livelyeb15d002018-10-29 18:38:12 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s --check-prefixes CHECK,SLOW
Wouter van Oortmerssen8a9cb242018-08-27 15:45:51 +00002; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -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"
Sam Clegga5908002018-05-10 17:49:11 +00007target triple = "wasm32-unknown-unknown"
Derek Schuff6b5c6da2015-11-03 22:40:40 +00008
Dan Gohmand9b42182015-11-25 22:13:48 +00009; CHECK-LABEL: select_i32_bool:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000010; CHECK-NEXT: .functype select_i32_bool (i32, i32, i32) -> (i32){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000011; CHECK-NEXT: i32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000012; CHECK-NEXT: return $pop0{{$}}
13define i32 @select_i32_bool(i1 zeroext %a, i32 %b, i32 %c) {
14 %cond = select i1 %a, i32 %b, i32 %c
15 ret i32 %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +000016}
17
Thomas Livelyeb15d002018-10-29 18:38:12 +000018; CHECK-LABEL: select_i32_bool_nozext:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000019; CHECK-NEXT: .functype select_i32_bool_nozext (i32, i32, i32) -> (i32){{$}}
Thomas Livelyeb15d002018-10-29 18:38:12 +000020; SLOW-NEXT: i32.select $push0=, $1, $2, $0{{$}}
21; SLOW-NEXT: return $pop0{{$}}
22define i32 @select_i32_bool_nozext(i1 %a, i32 %b, i32 %c) {
23 %cond = select i1 %a, i32 %b, i32 %c
24 ret i32 %cond
25}
26
Dan Gohmand9b42182015-11-25 22:13:48 +000027; CHECK-LABEL: select_i32_eq:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000028; CHECK-NEXT: .functype select_i32_eq (i32, i32, i32) -> (i32){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000029; CHECK-NEXT: i32.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000030; CHECK-NEXT: return $pop0{{$}}
31define i32 @select_i32_eq(i32 %a, i32 %b, i32 %c) {
32 %cmp = icmp eq i32 %a, 0
33 %cond = select i1 %cmp, i32 %b, i32 %c
34 ret i32 %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +000035}
36
Dan Gohmand9b42182015-11-25 22:13:48 +000037; CHECK-LABEL: select_i32_ne:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000038; CHECK-NEXT: .functype select_i32_ne (i32, i32, i32) -> (i32){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000039; CHECK-NEXT: i32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000040; CHECK-NEXT: return $pop0{{$}}
41define i32 @select_i32_ne(i32 %a, i32 %b, i32 %c) {
42 %cmp = icmp ne i32 %a, 0
43 %cond = select i1 %cmp, i32 %b, i32 %c
44 ret i32 %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +000045}
46
Dan Gohmand9b42182015-11-25 22:13:48 +000047; CHECK-LABEL: select_i64_bool:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000048; CHECK-NEXT: .functype select_i64_bool (i32, i64, i64) -> (i64){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000049; CHECK-NEXT: i64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000050; CHECK-NEXT: return $pop0{{$}}
51define i64 @select_i64_bool(i1 zeroext %a, i64 %b, i64 %c) {
52 %cond = select i1 %a, i64 %b, i64 %c
53 ret i64 %cond
54}
55
Thomas Livelyeb15d002018-10-29 18:38:12 +000056; CHECK-LABEL: select_i64_bool_nozext:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000057; CHECK-NEXT: .functype select_i64_bool_nozext (i32, i64, i64) -> (i64){{$}}
Thomas Livelyeb15d002018-10-29 18:38:12 +000058; SLOW-NEXT: i64.select $push0=, $1, $2, $0{{$}}
59; SLOW-NEXT: return $pop0{{$}}
60define i64 @select_i64_bool_nozext(i1 %a, i64 %b, i64 %c) {
61 %cond = select i1 %a, i64 %b, i64 %c
62 ret i64 %cond
63}
64
Dan Gohmand9b42182015-11-25 22:13:48 +000065; CHECK-LABEL: select_i64_eq:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000066; CHECK-NEXT: .functype select_i64_eq (i32, i64, i64) -> (i64){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000067; CHECK-NEXT: i64.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000068; CHECK-NEXT: return $pop0{{$}}
69define i64 @select_i64_eq(i32 %a, i64 %b, i64 %c) {
70 %cmp = icmp eq i32 %a, 0
71 %cond = select i1 %cmp, i64 %b, i64 %c
72 ret i64 %cond
73}
74
75; CHECK-LABEL: select_i64_ne:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000076; CHECK-NEXT: .functype select_i64_ne (i32, i64, i64) -> (i64){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000077; CHECK-NEXT: i64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000078; CHECK-NEXT: return $pop0{{$}}
79define i64 @select_i64_ne(i32 %a, i64 %b, i64 %c) {
80 %cmp = icmp ne i32 %a, 0
81 %cond = select i1 %cmp, i64 %b, i64 %c
82 ret i64 %cond
83}
84
85; CHECK-LABEL: select_f32_bool:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000086; CHECK-NEXT: .functype select_f32_bool (i32, f32, f32) -> (f32){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +000087; CHECK-NEXT: f32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +000088; CHECK-NEXT: return $pop0{{$}}
89define float @select_f32_bool(i1 zeroext %a, float %b, float %c) {
90 %cond = select i1 %a, float %b, float %c
91 ret float %cond
92}
93
Thomas Livelyeb15d002018-10-29 18:38:12 +000094; CHECK-LABEL: select_f32_bool_nozext:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000095; CHECK-NEXT: .functype select_f32_bool_nozext (i32, f32, f32) -> (f32){{$}}
Thomas Livelyeb15d002018-10-29 18:38:12 +000096; SLOW-NEXT: f32.select $push0=, $1, $2, $0{{$}}
97; SLOW-NEXT: return $pop0{{$}}
98define float @select_f32_bool_nozext(i1 %a, float %b, float %c) {
99 %cond = select i1 %a, float %b, float %c
100 ret float %cond
101}
102
Dan Gohmand9b42182015-11-25 22:13:48 +0000103; CHECK-LABEL: select_f32_eq:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000104; CHECK-NEXT: .functype select_f32_eq (i32, f32, f32) -> (f32){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000105; CHECK-NEXT: f32.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000106; CHECK-NEXT: return $pop0{{$}}
107define float @select_f32_eq(i32 %a, float %b, float %c) {
108 %cmp = icmp eq i32 %a, 0
109 %cond = select i1 %cmp, float %b, float %c
110 ret float %cond
111}
112
113; CHECK-LABEL: select_f32_ne:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000114; CHECK-NEXT: .functype select_f32_ne (i32, f32, f32) -> (f32){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000115; CHECK-NEXT: f32.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000116; CHECK-NEXT: return $pop0{{$}}
117define float @select_f32_ne(i32 %a, float %b, float %c) {
118 %cmp = icmp ne i32 %a, 0
119 %cond = select i1 %cmp, float %b, float %c
120 ret float %cond
121}
122
123; CHECK-LABEL: select_f64_bool:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000124; CHECK-NEXT: .functype select_f64_bool (i32, f64, f64) -> (f64){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000125; CHECK-NEXT: f64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000126; CHECK-NEXT: return $pop0{{$}}
127define double @select_f64_bool(i1 zeroext %a, double %b, double %c) {
128 %cond = select i1 %a, double %b, double %c
129 ret double %cond
130}
131
Thomas Livelyeb15d002018-10-29 18:38:12 +0000132; CHECK-LABEL: select_f64_bool_nozext:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000133; CHECK-NEXT: .functype select_f64_bool_nozext (i32, f64, f64) -> (f64){{$}}
Thomas Livelyeb15d002018-10-29 18:38:12 +0000134; SLOW-NEXT: f64.select $push0=, $1, $2, $0{{$}}
135; SLOW-NEXT: return $pop0{{$}}
136define double @select_f64_bool_nozext(i1 %a, double %b, double %c) {
137 %cond = select i1 %a, double %b, double %c
138 ret double %cond
139}
140
Dan Gohmand9b42182015-11-25 22:13:48 +0000141; CHECK-LABEL: select_f64_eq:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000142; CHECK-NEXT: .functype select_f64_eq (i32, f64, f64) -> (f64){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000143; CHECK-NEXT: f64.select $push0=, $2, $1, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000144; CHECK-NEXT: return $pop0{{$}}
145define double @select_f64_eq(i32 %a, double %b, double %c) {
146 %cmp = icmp eq i32 %a, 0
147 %cond = select i1 %cmp, double %b, double %c
148 ret double %cond
149}
150
151; CHECK-LABEL: select_f64_ne:
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000152; CHECK-NEXT: .functype select_f64_ne (i32, f64, f64) -> (f64){{$}}
Dan Gohmand46b0922016-02-05 17:14:59 +0000153; CHECK-NEXT: f64.select $push0=, $1, $2, $0{{$}}
Dan Gohmand9b42182015-11-25 22:13:48 +0000154; CHECK-NEXT: return $pop0{{$}}
155define double @select_f64_ne(i32 %a, double %b, double %c) {
156 %cmp = icmp ne i32 %a, 0
157 %cond = select i1 %cmp, double %b, double %c
158 ret double %cond
Derek Schuff6b5c6da2015-11-03 22:40:40 +0000159}