blob: 93e7ef7fe248f600c331a1bab8092bedbe54eb08 [file] [log] [blame]
JF Bastien8f9aea02015-08-01 04:48:44 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test that basic 64-bit integer operations assemble as expected.
4
Dan Gohmandde8dce2015-08-19 20:30:20 +00005target datalayout = "e-p:32:32-i64:64-n32:64-S128"
JF Bastien8f9aea02015-08-01 04:48:44 +00006target triple = "wasm32-unknown-unknown"
7
8declare i64 @llvm.ctlz.i64(i64, i1)
9declare i64 @llvm.cttz.i64(i64, i1)
10declare i64 @llvm.ctpop.i64(i64)
11
Dan Gohmane51c0582015-10-06 00:27:55 +000012; CHECK-LABEL: add64:
13; CHECK-NEXT: .param i64{{$}}
14; CHECK-NEXT: .param i64{{$}}
15; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000016; CHECK-NEXT: i64.add $push0, $0, $1{{$}}
17; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000018define i64 @add64(i64 %x, i64 %y) {
19 %a = add i64 %x, %y
20 ret i64 %a
21}
22
Dan Gohmane51c0582015-10-06 00:27:55 +000023; CHECK-LABEL: sub64:
24; CHECK-NEXT: .param i64{{$}}
25; CHECK-NEXT: .param i64{{$}}
26; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000027; CHECK-NEXT: i64.sub $push0, $0, $1{{$}}
28; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000029define i64 @sub64(i64 %x, i64 %y) {
30 %a = sub i64 %x, %y
31 ret i64 %a
32}
33
Dan Gohmane51c0582015-10-06 00:27:55 +000034; CHECK-LABEL: mul64:
35; CHECK-NEXT: .param i64{{$}}
36; CHECK-NEXT: .param i64{{$}}
37; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000038; CHECK-NEXT: i64.mul $push0, $0, $1{{$}}
39; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000040define i64 @mul64(i64 %x, i64 %y) {
41 %a = mul i64 %x, %y
42 ret i64 %a
43}
44
Dan Gohmane51c0582015-10-06 00:27:55 +000045; CHECK-LABEL: sdiv64:
46; CHECK-NEXT: .param i64{{$}}
47; CHECK-NEXT: .param i64{{$}}
48; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000049; CHECK-NEXT: i64.div_s $push0, $0, $1{{$}}
50; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000051define i64 @sdiv64(i64 %x, i64 %y) {
52 %a = sdiv i64 %x, %y
53 ret i64 %a
54}
55
Dan Gohmane51c0582015-10-06 00:27:55 +000056; CHECK-LABEL: udiv64:
57; CHECK-NEXT: .param i64{{$}}
58; CHECK-NEXT: .param i64{{$}}
59; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000060; CHECK-NEXT: i64.div_u $push0, $0, $1{{$}}
61; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000062define i64 @udiv64(i64 %x, i64 %y) {
63 %a = udiv i64 %x, %y
64 ret i64 %a
65}
66
Dan Gohmane51c0582015-10-06 00:27:55 +000067; CHECK-LABEL: srem64:
68; CHECK-NEXT: .param i64{{$}}
69; CHECK-NEXT: .param i64{{$}}
70; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000071; CHECK-NEXT: i64.rem_s $push0, $0, $1{{$}}
72; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000073define i64 @srem64(i64 %x, i64 %y) {
74 %a = srem i64 %x, %y
75 ret i64 %a
76}
77
Dan Gohmane51c0582015-10-06 00:27:55 +000078; CHECK-LABEL: urem64:
79; CHECK-NEXT: .param i64{{$}}
80; CHECK-NEXT: .param i64{{$}}
81; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000082; CHECK-NEXT: i64.rem_u $push0, $0, $1{{$}}
83; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000084define i64 @urem64(i64 %x, i64 %y) {
85 %a = urem i64 %x, %y
86 ret i64 %a
87}
88
Dan Gohmane51c0582015-10-06 00:27:55 +000089; CHECK-LABEL: and64:
90; CHECK-NEXT: .param i64{{$}}
91; CHECK-NEXT: .param i64{{$}}
92; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000093; CHECK-NEXT: i64.and $push0, $0, $1{{$}}
94; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000095define i64 @and64(i64 %x, i64 %y) {
96 %a = and i64 %x, %y
97 ret i64 %a
98}
99
Derek Schuff8a76b042015-11-05 17:08:11 +0000100; CHECK-LABEL: or64:
Dan Gohmane51c0582015-10-06 00:27:55 +0000101; CHECK-NEXT: .param i64{{$}}
102; CHECK-NEXT: .param i64{{$}}
103; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000104; CHECK-NEXT: i64.or $push0, $0, $1{{$}}
105; CHECK-NEXT: return $pop0{{$}}
Derek Schuff8a76b042015-11-05 17:08:11 +0000106define i64 @or64(i64 %x, i64 %y) {
JF Bastien8f9aea02015-08-01 04:48:44 +0000107 %a = or i64 %x, %y
108 ret i64 %a
109}
110
Dan Gohmane51c0582015-10-06 00:27:55 +0000111; CHECK-LABEL: xor64:
112; CHECK-NEXT: .param i64{{$}}
113; CHECK-NEXT: .param i64{{$}}
114; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000115; CHECK-NEXT: i64.xor $push0, $0, $1{{$}}
116; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000117define i64 @xor64(i64 %x, i64 %y) {
118 %a = xor i64 %x, %y
119 ret i64 %a
120}
121
Dan Gohmane51c0582015-10-06 00:27:55 +0000122; CHECK-LABEL: shl64:
123; CHECK-NEXT: .param i64{{$}}
124; CHECK-NEXT: .param i64{{$}}
125; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000126; CHECK-NEXT: i64.shl $push0, $0, $1{{$}}
127; CHECK-NEXT: return $pop0{{$}}
JF Bastienfda53372015-08-03 00:00:11 +0000128define i64 @shl64(i64 %x, i64 %y) {
129 %a = shl i64 %x, %y
130 ret i64 %a
131}
JF Bastien8f9aea02015-08-01 04:48:44 +0000132
Dan Gohmane51c0582015-10-06 00:27:55 +0000133; CHECK-LABEL: shr64:
134; CHECK-NEXT: .param i64{{$}}
135; CHECK-NEXT: .param i64{{$}}
136; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000137; CHECK-NEXT: i64.shr_u $push0, $0, $1{{$}}
138; CHECK-NEXT: return $pop0{{$}}
JF Bastienfda53372015-08-03 00:00:11 +0000139define i64 @shr64(i64 %x, i64 %y) {
140 %a = lshr i64 %x, %y
141 ret i64 %a
142}
JF Bastien8f9aea02015-08-01 04:48:44 +0000143
Dan Gohmane51c0582015-10-06 00:27:55 +0000144; CHECK-LABEL: sar64:
145; CHECK-NEXT: .param i64{{$}}
146; CHECK-NEXT: .param i64{{$}}
147; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000148; CHECK-NEXT: i64.shr_s $push0, $0, $1{{$}}
149; CHECK-NEXT: return $pop0{{$}}
JF Bastienfda53372015-08-03 00:00:11 +0000150define i64 @sar64(i64 %x, i64 %y) {
151 %a = ashr i64 %x, %y
152 ret i64 %a
153}
JF Bastien8f9aea02015-08-01 04:48:44 +0000154
Dan Gohmane51c0582015-10-06 00:27:55 +0000155; CHECK-LABEL: clz64:
156; CHECK-NEXT: .param i64{{$}}
157; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000158; CHECK-NEXT: i64.clz $push0, $0{{$}}
159; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000160define i64 @clz64(i64 %x) {
161 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
162 ret i64 %a
163}
164
Dan Gohmane51c0582015-10-06 00:27:55 +0000165; CHECK-LABEL: clz64_zero_undef:
166; CHECK-NEXT: .param i64{{$}}
167; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000168; CHECK-NEXT: i64.clz $push0, $0{{$}}
169; CHECK-NEXT: return $pop0{{$}}
Dan Gohman08fc9662015-08-24 16:39:37 +0000170define i64 @clz64_zero_undef(i64 %x) {
171 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
172 ret i64 %a
173}
174
Dan Gohmane51c0582015-10-06 00:27:55 +0000175; CHECK-LABEL: ctz64:
176; CHECK-NEXT: .param i64{{$}}
177; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000178; CHECK-NEXT: i64.ctz $push0, $0{{$}}
179; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000180define i64 @ctz64(i64 %x) {
181 %a = call i64 @llvm.cttz.i64(i64 %x, i1 false)
182 ret i64 %a
183}
184
Dan Gohmane51c0582015-10-06 00:27:55 +0000185; CHECK-LABEL: ctz64_zero_undef:
186; CHECK-NEXT: .param i64{{$}}
187; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000188; CHECK-NEXT: i64.ctz $push0, $0{{$}}
189; CHECK-NEXT: return $pop0{{$}}
Dan Gohman08fc9662015-08-24 16:39:37 +0000190define i64 @ctz64_zero_undef(i64 %x) {
191 %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
192 ret i64 %a
193}
194
Dan Gohmane51c0582015-10-06 00:27:55 +0000195; CHECK-LABEL: popcnt64:
196; CHECK-NEXT: .param i64{{$}}
197; CHECK-NEXT: .result i64{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000198; CHECK-NEXT: i64.popcnt $push0, $0{{$}}
199; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000200define i64 @popcnt64(i64 %x) {
201 %a = call i64 @llvm.ctpop.i64(i64 %x)
202 ret i64 %a
203}