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 datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7 target triple = "wasm32-unknown-unknown"
10 ; CHECK-NEXT: .functype eq_i32 (i32, i32) -> (i32){{$}}
11 ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}}
12 ; CHECK-NEXT: local.get $push[[L1:[0-9]+]]=, 1{{$}}
13 ; CHECK-NEXT: i32.eq $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
14 ; SLOW-NEXT: return $pop[[L2]]{{$}}
15 ; FAST-NEXT: i32.const $push[[L3:[0-9]+]]=, 1{{$}}
16 ; FAST-NEXT: i32.and $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]]{{$}}
17 ; FAST-NEXT: return $pop[[L4]]{{$}}
18 define i32 @eq_i32(i32 %x, i32 %y) {
19 %a = icmp eq i32 %x, %y
20 %b = zext i1 %a to i32
24 ; CHECK-LABEL: ne_i32:
25 ; CHECK: i32.ne $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
26 ; SLOW-NEXT: return $pop[[L0]]{{$}}
27 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
28 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
29 ; FAST-NEXT: return $pop[[L2]]{{$}}
30 define i32 @ne_i32(i32 %x, i32 %y) {
31 %a = icmp ne i32 %x, %y
32 %b = zext i1 %a to i32
36 ; CHECK-LABEL: slt_i32:
37 ; CHECK: i32.lt_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
38 ; SLOW-NEXT: return $pop[[L0]]{{$}}
39 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
40 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
41 ; FAST-NEXT: return $pop[[L2]]{{$}}
42 define i32 @slt_i32(i32 %x, i32 %y) {
43 %a = icmp slt i32 %x, %y
44 %b = zext i1 %a to i32
48 ; CHECK-LABEL: sle_i32:
49 ; CHECK: i32.le_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
50 ; SLOW-NEXT: return $pop[[L0]]{{$}}
51 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
52 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
53 ; FAST-NEXT: return $pop[[L2]]{{$}}
54 define i32 @sle_i32(i32 %x, i32 %y) {
55 %a = icmp sle i32 %x, %y
56 %b = zext i1 %a to i32
60 ; CHECK-LABEL: ult_i32:
61 ; CHECK: i32.lt_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
62 ; SLOW-NEXT: return $pop[[L0]]{{$}}
63 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
64 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
65 ; FAST-NEXT: return $pop[[L2]]{{$}}
66 define i32 @ult_i32(i32 %x, i32 %y) {
67 %a = icmp ult i32 %x, %y
68 %b = zext i1 %a to i32
72 ; CHECK-LABEL: ule_i32:
73 ; CHECK: i32.le_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
74 ; SLOW-NEXT: return $pop[[L0]]{{$}}
75 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
76 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
77 ; FAST-NEXT: return $pop[[L2]]{{$}}
78 define i32 @ule_i32(i32 %x, i32 %y) {
79 %a = icmp ule i32 %x, %y
80 %b = zext i1 %a to i32
84 ; CHECK-LABEL: sgt_i32:
85 ; CHECK: i32.gt_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
86 ; SLOW-NEXT: return $pop[[L0]]{{$}}
87 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
88 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
89 ; FAST-NEXT: return $pop[[L2]]{{$}}
90 define i32 @sgt_i32(i32 %x, i32 %y) {
91 %a = icmp sgt i32 %x, %y
92 %b = zext i1 %a to i32
96 ; CHECK-LABEL: sge_i32:
97 ; CHECK: i32.ge_s $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
98 ; SLOW-NEXT: return $pop[[L0]]{{$}}
99 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
100 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
101 ; FAST-NEXT: return $pop[[L2]]{{$}}
102 define i32 @sge_i32(i32 %x, i32 %y) {
103 %a = icmp sge i32 %x, %y
104 %b = zext i1 %a to i32
108 ; CHECK-LABEL: ugt_i32:
109 ; CHECK: i32.gt_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
110 ; SLOW-NEXT: return $pop[[L0]]{{$}}
111 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
112 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
113 ; FAST-NEXT: return $pop[[L2]]{{$}}
114 define i32 @ugt_i32(i32 %x, i32 %y) {
115 %a = icmp ugt i32 %x, %y
116 %b = zext i1 %a to i32
120 ; CHECK-LABEL: uge_i32:
121 ; CHECK: i32.ge_u $push[[L0:[0-9]+]]=, $pop{{[0-9]+}}, $pop{{[0-9]+}}{{$}}
122 ; SLOW-NEXT: return $pop[[L0]]{{$}}
123 ; FAST-NEXT: i32.const $push[[L1:[0-9]+]]=, 1{{$}}
124 ; FAST-NEXT: i32.and $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
125 ; FAST-NEXT: return $pop[[L2]]{{$}}
126 define i32 @uge_i32(i32 %x, i32 %y) {
127 %a = icmp uge i32 %x, %y
128 %b = zext i1 %a to i32