• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
4; Test that basic 64-bit integer comparison operations assemble as expected.
5
6target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7target triple = "wasm32-unknown-unknown"
8
9; CHECK-LABEL: eq_i64:
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]]{{$}}
18define i32 @eq_i64(i64 %x, i64 %y) {
19  %a = icmp eq i64 %x, %y
20  %b = zext i1 %a to i32
21  ret i32 %b
22}
23
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]]{{$}}
30define i32 @ne_i64(i64 %x, i64 %y) {
31  %a = icmp ne i64 %x, %y
32  %b = zext i1 %a to i32
33  ret i32 %b
34}
35
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]]{{$}}
42define i32 @slt_i64(i64 %x, i64 %y) {
43  %a = icmp slt i64 %x, %y
44  %b = zext i1 %a to i32
45  ret i32 %b
46}
47
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]]{{$}}
54define i32 @sle_i64(i64 %x, i64 %y) {
55  %a = icmp sle i64 %x, %y
56  %b = zext i1 %a to i32
57  ret i32 %b
58}
59
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]]{{$}}
66define i32 @ult_i64(i64 %x, i64 %y) {
67  %a = icmp ult i64 %x, %y
68  %b = zext i1 %a to i32
69  ret i32 %b
70}
71
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]]{{$}}
78define i32 @ule_i64(i64 %x, i64 %y) {
79  %a = icmp ule i64 %x, %y
80  %b = zext i1 %a to i32
81  ret i32 %b
82}
83
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]]{{$}}
90define i32 @sgt_i64(i64 %x, i64 %y) {
91  %a = icmp sgt i64 %x, %y
92  %b = zext i1 %a to i32
93  ret i32 %b
94}
95
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]]{{$}}
102define i32 @sge_i64(i64 %x, i64 %y) {
103  %a = icmp sge i64 %x, %y
104  %b = zext i1 %a to i32
105  ret i32 %b
106}
107
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]]{{$}}
114define i32 @ugt_i64(i64 %x, i64 %y) {
115  %a = icmp ugt i64 %x, %y
116  %b = zext i1 %a to i32
117  ret i32 %b
118}
119
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]]{{$}}
126define i32 @uge_i64(i64 %x, i64 %y) {
127  %a = icmp uge i64 %x, %y
128  %b = zext i1 %a to i32
129  ret i32 %b
130}
131