blob: 4648fef1f093537e15935b68a002805bcc68f8e5 [file] [log] [blame]
JF Bastienda06bce2015-08-11 21:02:46 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test that basic 32-bit floating-point comparison operations assemble as
4; expected.
5
Dan Gohmandde8dce2015-08-19 20:30:20 +00006target datalayout = "e-p:32:32-i64:64-n32:64-S128"
JF Bastienda06bce2015-08-11 21:02:46 +00007target triple = "wasm32-unknown-unknown"
8
Dan Gohmane51c0582015-10-06 00:27:55 +00009; CHECK-LABEL: ord_f32:
10; CHECK-NEXT: .param f32{{$}}
11; CHECK-NEXT: .param f32{{$}}
12; CHECK-NEXT: .result i32{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000013; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000014; CHECK-NEXT: get_local push, 0{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000015; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000016; CHECK-NEXT: get_local push, 1{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000017; CHECK-NEXT: set_local 3, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000018; CHECK-NEXT: f32.eq push, (get_local 3), (get_local 3){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000019; CHECK-NEXT: set_local 4, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000020; CHECK-NEXT: f32.eq push, (get_local 2), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000021; CHECK-NEXT: set_local 5, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000022; CHECK-NEXT: i32.and push, (get_local 5), (get_local 4){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000023; CHECK-NEXT: set_local 6, pop{{$}}
24; CHECK-NEXT: return (get_local 6){{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +000025define i32 @ord_f32(float %x, float %y) {
26 %a = fcmp ord float %x, %y
27 %b = zext i1 %a to i32
28 ret i32 %b
29}
30
Dan Gohmane51c0582015-10-06 00:27:55 +000031; CHECK-LABEL: uno_f32:
32; CHECK-NEXT: .param f32{{$}}
33; CHECK-NEXT: .param f32{{$}}
34; CHECK-NEXT: .result i32{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000035; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000036; CHECK-NEXT: get_local push, 0{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000037; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000038; CHECK-NEXT: get_local push, 1{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000039; CHECK-NEXT: set_local 3, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000040; CHECK-NEXT: f32.ne push, (get_local 3), (get_local 3){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000041; CHECK-NEXT: set_local 4, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000042; CHECK-NEXT: f32.ne push, (get_local 2), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000043; CHECK-NEXT: set_local 5, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000044; CHECK-NEXT: i32.or push, (get_local 5), (get_local 4){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000045; CHECK-NEXT: set_local 6, pop{{$}}
46; CHECK-NEXT: return (get_local 6){{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +000047define i32 @uno_f32(float %x, float %y) {
48 %a = fcmp uno float %x, %y
49 %b = zext i1 %a to i32
50 ret i32 %b
51}
JF Bastienda06bce2015-08-11 21:02:46 +000052
Dan Gohmane51c0582015-10-06 00:27:55 +000053; CHECK-LABEL: oeq_f32:
54; CHECK-NEXT: .param f32{{$}}
55; CHECK-NEXT: .param f32{{$}}
56; CHECK-NEXT: .result i32{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000057; CHECK-NEXT: .local f32, f32, i32{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000058; CHECK-NEXT: get_local push, 1{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000059; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +000060; CHECK-NEXT: get_local push, 0{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000061; CHECK-NEXT: set_local 3, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +000062; CHECK-NEXT: f32.eq push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000063; CHECK-NEXT: set_local 4, pop{{$}}
64; CHECK-NEXT: return (get_local 4){{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000065define i32 @oeq_f32(float %x, float %y) {
66 %a = fcmp oeq float %x, %y
67 %b = zext i1 %a to i32
68 ret i32 %b
69}
70
Dan Gohmane51c0582015-10-06 00:27:55 +000071; CHECK-LABEL: une_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +000072; CHECK: f32.ne push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000073; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000074define i32 @une_f32(float %x, float %y) {
75 %a = fcmp une float %x, %y
76 %b = zext i1 %a to i32
77 ret i32 %b
78}
79
Dan Gohmane51c0582015-10-06 00:27:55 +000080; CHECK-LABEL: olt_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +000081; CHECK: f32.lt push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000082; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000083define i32 @olt_f32(float %x, float %y) {
84 %a = fcmp olt float %x, %y
85 %b = zext i1 %a to i32
86 ret i32 %b
87}
88
Dan Gohmane51c0582015-10-06 00:27:55 +000089; CHECK-LABEL: ole_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +000090; CHECK: f32.le push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +000091; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000092define i32 @ole_f32(float %x, float %y) {
93 %a = fcmp ole float %x, %y
94 %b = zext i1 %a to i32
95 ret i32 %b
96}
97
Dan Gohmane51c0582015-10-06 00:27:55 +000098; CHECK-LABEL: ogt_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +000099; CHECK: f32.gt push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000100; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +0000101define i32 @ogt_f32(float %x, float %y) {
102 %a = fcmp ogt float %x, %y
103 %b = zext i1 %a to i32
104 ret i32 %b
105}
106
Dan Gohmane51c0582015-10-06 00:27:55 +0000107; CHECK-LABEL: oge_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +0000108; CHECK: f32.ge push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000109; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +0000110define i32 @oge_f32(float %x, float %y) {
111 %a = fcmp oge float %x, %y
112 %b = zext i1 %a to i32
113 ret i32 %b
114}
115
JF Bastien71d29ac2015-08-12 17:53:29 +0000116; Expanded comparisons, which also check for NaN.
117
Dan Gohmane51c0582015-10-06 00:27:55 +0000118; CHECK-LABEL: ueq_f32:
119; CHECK-NEXT: .param f32{{$}}
120; CHECK-NEXT: .param f32{{$}}
121; CHECK-NEXT: .result i32{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000122; CHECK-NEXT: .local f32, f32, i32, i32, i32, i32, i32{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +0000123; CHECK-NEXT: get_local push, 1{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000124; CHECK-NEXT: set_local 2, pop{{$}}
Dan Gohman8d456e42015-11-06 21:26:50 +0000125; CHECK-NEXT: get_local push, 0{{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000126; CHECK-NEXT: set_local 3, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +0000127; CHECK-NEXT: f32.eq push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000128; CHECK-NEXT: set_local 4, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +0000129; CHECK-NEXT: f32.ne push, (get_local 2), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000130; CHECK-NEXT: set_local 5, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +0000131; CHECK-NEXT: f32.ne push, (get_local 3), (get_local 3){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000132; CHECK-NEXT: set_local 6, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +0000133; CHECK-NEXT: i32.or push, (get_local 6), (get_local 5){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000134; CHECK-NEXT: set_local 7, pop{{$}}
Dan Gohman3cb66c82015-11-06 21:32:42 +0000135; CHECK-NEXT: i32.or push, (get_local 4), (get_local 7){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000136; CHECK-NEXT: set_local 8, pop{{$}}
137; CHECK-NEXT: return (get_local 8){{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +0000138define i32 @ueq_f32(float %x, float %y) {
139 %a = fcmp ueq float %x, %y
140 %b = zext i1 %a to i32
141 ret i32 %b
142}
143
Dan Gohmane51c0582015-10-06 00:27:55 +0000144; CHECK-LABEL: one_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +0000145; CHECK: f32.ne push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000146; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +0000147define i32 @one_f32(float %x, float %y) {
148 %a = fcmp one float %x, %y
149 %b = zext i1 %a to i32
150 ret i32 %b
151}
152
Dan Gohmane51c0582015-10-06 00:27:55 +0000153; CHECK-LABEL: ult_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +0000154; CHECK: f32.lt push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000155; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +0000156define i32 @ult_f32(float %x, float %y) {
157 %a = fcmp ult float %x, %y
158 %b = zext i1 %a to i32
159 ret i32 %b
160}
161
Dan Gohmane51c0582015-10-06 00:27:55 +0000162; CHECK-LABEL: ule_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +0000163; CHECK: f32.le push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000164; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +0000165define i32 @ule_f32(float %x, float %y) {
166 %a = fcmp ule float %x, %y
167 %b = zext i1 %a to i32
168 ret i32 %b
169}
170
Dan Gohmane51c0582015-10-06 00:27:55 +0000171; CHECK-LABEL: ugt_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +0000172; CHECK: f32.gt push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000173; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +0000174define i32 @ugt_f32(float %x, float %y) {
175 %a = fcmp ugt float %x, %y
176 %b = zext i1 %a to i32
177 ret i32 %b
178}
179
Dan Gohmane51c0582015-10-06 00:27:55 +0000180; CHECK-LABEL: uge_f32:
Dan Gohman3cb66c82015-11-06 21:32:42 +0000181; CHECK: f32.ge push, (get_local 3), (get_local 2){{$}}
JF Bastien1d20a5e2015-10-16 00:53:49 +0000182; CHECK-NEXT: set_local 4, pop{{$}}
JF Bastien71d29ac2015-08-12 17:53:29 +0000183define i32 @uge_f32(float %x, float %y) {
184 %a = fcmp uge float %x, %y
185 %b = zext i1 %a to i32
186 ret i32 %b
187}