1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s --check-prefixes CHECK,SLOW
2 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes CHECK,FAST
4 ; Test that basic 32-bit integer comparison operations assemble as expected.
6 target triple = "wasm32-unknown-unknown"
9 ; CHECK-NEXT: .functype eq_i32 (i32, i32) -> (i32){{$}}
10 ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}}
11 ; CHECK-NEXT: local.get $push[[L1:[0-9]+]]=, 1{{$}}
12 ; CHECK-NEXT: i32.eq $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
13 ; SLOW-NEXT: return $pop[[L2]]{{$}}
14 ; FAST-NEXT: i32.const $push[[L3:[0-9]+]]=, 1{{$}}
15 ; FAST-NEXT: i32.and $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]]{{$}}
16 ; FAST-NEXT: return $pop[[L4]]{{$}}
17 define i32 @eq_i32(i32 %x, i32 %y) {
18 %a = icmp eq i32 %x, %y
19 %b = zext i1 %a to i32
23 ; CHECK-LABEL: ne_i32:
24 ; CHECK: i32.ne $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
25 ; SLOW-NEXT: return $pop[[L0]]{{$}}
26 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
27 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
28 ; FAST-NEXT: return $pop[[L2]]{{$}}
29 define i32 @ne_i32(i32 %x, i32 %y) {
30 %a = icmp ne i32 %x, %y
31 %b = zext i1 %a to i32
35 ; CHECK-LABEL: slt_i32:
36 ; CHECK: i32.lt_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
37 ; SLOW-NEXT: return $pop[[L0]]{{$}}
38 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
39 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
40 ; FAST-NEXT: return $pop[[L2]]{{$}}
41 define i32 @slt_i32(i32 %x, i32 %y) {
42 %a = icmp slt i32 %x, %y
43 %b = zext i1 %a to i32
47 ; CHECK-LABEL: sle_i32:
48 ; CHECK: i32.le_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
49 ; SLOW-NEXT: return $pop[[L0]]{{$}}
50 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
51 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
52 ; FAST-NEXT: return $pop[[L2]]{{$}}
53 define i32 @sle_i32(i32 %x, i32 %y) {
54 %a = icmp sle i32 %x, %y
55 %b = zext i1 %a to i32
59 ; CHECK-LABEL: ult_i32:
60 ; CHECK: i32.lt_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
61 ; SLOW-NEXT: return $pop[[L0]]{{$}}
62 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
63 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
64 ; FAST-NEXT: return $pop[[L2]]{{$}}
65 define i32 @ult_i32(i32 %x, i32 %y) {
66 %a = icmp ult i32 %x, %y
67 %b = zext i1 %a to i32
71 ; CHECK-LABEL: ule_i32:
72 ; CHECK: i32.le_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
73 ; SLOW-NEXT: return $pop[[L0]]{{$}}
74 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
75 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
76 ; FAST-NEXT: return $pop[[L2]]{{$}}
77 define i32 @ule_i32(i32 %x, i32 %y) {
78 %a = icmp ule i32 %x, %y
79 %b = zext i1 %a to i32
83 ; CHECK-LABEL: sgt_i32:
84 ; CHECK: i32.gt_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
85 ; SLOW-NEXT: return $pop[[L0]]{{$}}
86 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
87 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
88 ; FAST-NEXT: return $pop[[L2]]{{$}}
89 define i32 @sgt_i32(i32 %x, i32 %y) {
90 %a = icmp sgt i32 %x, %y
91 %b = zext i1 %a to i32
95 ; CHECK-LABEL: sge_i32:
96 ; CHECK: i32.ge_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
97 ; SLOW-NEXT: return $pop[[L0]]{{$}}
98 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
99 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
100 ; FAST-NEXT: return $pop[[L2]]{{$}}
101 define i32 @sge_i32(i32 %x, i32 %y) {
102 %a = icmp sge i32 %x, %y
103 %b = zext i1 %a to i32
107 ; CHECK-LABEL: ugt_i32:
108 ; CHECK: i32.gt_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
109 ; SLOW-NEXT: return $pop[[L0]]{{$}}
110 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
111 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
112 ; FAST-NEXT: return $pop[[L2]]{{$}}
113 define i32 @ugt_i32(i32 %x, i32 %y) {
114 %a = icmp ugt i32 %x, %y
115 %b = zext i1 %a to i32
119 ; CHECK-LABEL: uge_i32:
120 ; CHECK: i32.ge_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
121 ; SLOW-NEXT: return $pop[[L0]]{{$}}
122 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
123 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
124 ; FAST-NEXT: return $pop[[L2]]{{$}}
125 define i32 @uge_i32(i32 %x, i32 %y) {
126 %a = icmp uge i32 %x, %y
127 %b = zext i1 %a to i32