blob: a9a79c24fb47734b5616db75499b456327622cbc [file] [log] [blame]
Dan Gohmanb7c24002016-05-21 00:21:56 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
2; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -fast-isel -fast-isel-abort=1 | FileCheck %s
JF Bastienda06bce2015-08-11 21:02:46 +00003
4; Test that basic 32-bit integer comparison operations assemble as expected.
5
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00006target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohmand934cb82017-02-24 23:18:00 +00007target triple = "wasm32-unknown-unknown-wasm"
JF Bastienda06bce2015-08-11 21:02:46 +00008
Dan Gohmane51c0582015-10-06 00:27:55 +00009; CHECK-LABEL: eq_i32:
Dan Gohman53828fd2015-11-23 16:50:18 +000010; CHECK-NEXT: .param i32, i32{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000011; CHECK-NEXT: .result i32{{$}}
Dan Gohmand934cb82017-02-24 23:18:00 +000012; CHECK-NEXT: get_local $push[[L0:[0-9]+]]=, 0{{$}}
13; CHECK-NEXT: get_local $push[[L1:[0-9]+]]=, 1{{$}}
14; CHECK-NEXT: i32.eq $push[[NUM:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000015; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000016define i32 @eq_i32(i32 %x, i32 %y) {
17 %a = icmp eq i32 %x, %y
18 %b = zext i1 %a to i32
19 ret i32 %b
20}
21
Dan Gohmane51c0582015-10-06 00:27:55 +000022; CHECK-LABEL: ne_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000023; CHECK: i32.ne $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000024; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000025define i32 @ne_i32(i32 %x, i32 %y) {
26 %a = icmp ne i32 %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: slt_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000032; CHECK: i32.lt_s $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000033; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000034define i32 @slt_i32(i32 %x, i32 %y) {
35 %a = icmp slt i32 %x, %y
36 %b = zext i1 %a to i32
37 ret i32 %b
38}
39
Dan Gohmane51c0582015-10-06 00:27:55 +000040; CHECK-LABEL: sle_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000041; CHECK: i32.le_s $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000042; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000043define i32 @sle_i32(i32 %x, i32 %y) {
44 %a = icmp sle i32 %x, %y
45 %b = zext i1 %a to i32
46 ret i32 %b
47}
48
Dan Gohmane51c0582015-10-06 00:27:55 +000049; CHECK-LABEL: ult_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000050; CHECK: i32.lt_u $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000051; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000052define i32 @ult_i32(i32 %x, i32 %y) {
53 %a = icmp ult i32 %x, %y
54 %b = zext i1 %a to i32
55 ret i32 %b
56}
57
Dan Gohmane51c0582015-10-06 00:27:55 +000058; CHECK-LABEL: ule_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000059; CHECK: i32.le_u $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000060; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000061define i32 @ule_i32(i32 %x, i32 %y) {
62 %a = icmp ule i32 %x, %y
63 %b = zext i1 %a to i32
64 ret i32 %b
65}
66
Dan Gohmane51c0582015-10-06 00:27:55 +000067; CHECK-LABEL: sgt_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000068; CHECK: i32.gt_s $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000069; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000070define i32 @sgt_i32(i32 %x, i32 %y) {
71 %a = icmp sgt i32 %x, %y
72 %b = zext i1 %a to i32
73 ret i32 %b
74}
75
Dan Gohmane51c0582015-10-06 00:27:55 +000076; CHECK-LABEL: sge_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000077; CHECK: i32.ge_s $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000078; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000079define i32 @sge_i32(i32 %x, i32 %y) {
80 %a = icmp sge i32 %x, %y
81 %b = zext i1 %a to i32
82 ret i32 %b
83}
84
Dan Gohmane51c0582015-10-06 00:27:55 +000085; CHECK-LABEL: ugt_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000086; CHECK: i32.gt_u $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000087; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000088define i32 @ugt_i32(i32 %x, i32 %y) {
89 %a = icmp ugt i32 %x, %y
90 %b = zext i1 %a to i32
91 ret i32 %b
92}
93
Dan Gohmane51c0582015-10-06 00:27:55 +000094; CHECK-LABEL: uge_i32:
Dan Gohmand934cb82017-02-24 23:18:00 +000095; CHECK: i32.ge_u $push[[NUM:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000096; CHECK-NEXT: return $pop[[NUM]]{{$}}
JF Bastienda06bce2015-08-11 21:02:46 +000097define i32 @uge_i32(i32 %x, i32 %y) {
98 %a = icmp uge i32 %x, %y
99 %b = zext i1 %a to i32
100 ret i32 %b
101}