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 64-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_i64 (i64, i64) -> (i32){{$}}
11 ; CHECK-NEXT: local.get $push[[L0:[0-9]+]]=, 0{{$}}
12 ; CHECK-NEXT: local.get $push[[L1:[0-9]+]]=, 1{{$}}
13 ; CHECK-NEXT: i64.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_i64(i64 %x, i64 %y) {
19 %a = icmp eq i64 %x, %y
20 %b = zext i1 %a to i32
24 ; CHECK-LABEL: ne_i64:
25 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
31 %a = icmp ne i64 %x, %y
32 %b = zext i1 %a to i32
36 ; CHECK-LABEL: slt_i64:
37 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
43 %a = icmp slt i64 %x, %y
44 %b = zext i1 %a to i32
48 ; CHECK-LABEL: sle_i64:
49 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
55 %a = icmp sle i64 %x, %y
56 %b = zext i1 %a to i32
60 ; CHECK-LABEL: ult_i64:
61 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
67 %a = icmp ult i64 %x, %y
68 %b = zext i1 %a to i32
72 ; CHECK-LABEL: ule_i64:
73 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
79 %a = icmp ule i64 %x, %y
80 %b = zext i1 %a to i32
84 ; CHECK-LABEL: sgt_i64:
85 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
91 %a = icmp sgt i64 %x, %y
92 %b = zext i1 %a to i32
96 ; CHECK-LABEL: sge_i64:
97 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
103 %a = icmp sge i64 %x, %y
104 %b = zext i1 %a to i32
108 ; CHECK-LABEL: ugt_i64:
109 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
115 %a = icmp ugt i64 %x, %y
116 %b = zext i1 %a to i32
120 ; CHECK-LABEL: uge_i64:
121 ; CHECK: i64.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_i64(i64 %x, i64 %y) {
127 %a = icmp uge i64 %x, %y
128 %b = zext i1 %a to i32