blob: c2a1bb6b970676ca96facb6856f06a36526656e4 [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 Gohman0c6f5ac2016-01-07 03:19:23 +00005target datalayout = "e-m: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:
Dan Gohman53828fd2015-11-23 16:50:18 +000013; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000014; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000015; CHECK-NEXT: i64.add $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000016; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000017define i64 @add64(i64 %x, i64 %y) {
18 %a = add i64 %x, %y
19 ret i64 %a
20}
21
Dan Gohmane51c0582015-10-06 00:27:55 +000022; CHECK-LABEL: sub64:
Dan Gohman53828fd2015-11-23 16:50:18 +000023; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000024; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000025; CHECK-NEXT: i64.sub $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000026; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000027define i64 @sub64(i64 %x, i64 %y) {
28 %a = sub i64 %x, %y
29 ret i64 %a
30}
31
Dan Gohmane51c0582015-10-06 00:27:55 +000032; CHECK-LABEL: mul64:
Dan Gohman53828fd2015-11-23 16:50:18 +000033; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000034; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000035; CHECK-NEXT: i64.mul $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000036; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000037define i64 @mul64(i64 %x, i64 %y) {
38 %a = mul i64 %x, %y
39 ret i64 %a
40}
41
Dan Gohmane51c0582015-10-06 00:27:55 +000042; CHECK-LABEL: sdiv64:
Dan Gohman53828fd2015-11-23 16:50:18 +000043; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000044; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000045; CHECK-NEXT: i64.div_s $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000046; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000047define i64 @sdiv64(i64 %x, i64 %y) {
48 %a = sdiv i64 %x, %y
49 ret i64 %a
50}
51
Dan Gohmane51c0582015-10-06 00:27:55 +000052; CHECK-LABEL: udiv64:
Dan Gohman53828fd2015-11-23 16:50:18 +000053; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000054; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000055; CHECK-NEXT: i64.div_u $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000056; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000057define i64 @udiv64(i64 %x, i64 %y) {
58 %a = udiv i64 %x, %y
59 ret i64 %a
60}
61
Dan Gohmane51c0582015-10-06 00:27:55 +000062; CHECK-LABEL: srem64:
Dan Gohman53828fd2015-11-23 16:50:18 +000063; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000064; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000065; CHECK-NEXT: i64.rem_s $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000066; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000067define i64 @srem64(i64 %x, i64 %y) {
68 %a = srem i64 %x, %y
69 ret i64 %a
70}
71
Dan Gohmane51c0582015-10-06 00:27:55 +000072; CHECK-LABEL: urem64:
Dan Gohman53828fd2015-11-23 16:50:18 +000073; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000074; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000075; CHECK-NEXT: i64.rem_u $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000076; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000077define i64 @urem64(i64 %x, i64 %y) {
78 %a = urem i64 %x, %y
79 ret i64 %a
80}
81
Dan Gohmane51c0582015-10-06 00:27:55 +000082; CHECK-LABEL: and64:
Dan Gohman53828fd2015-11-23 16:50:18 +000083; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000084; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000085; CHECK-NEXT: i64.and $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000086; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +000087define i64 @and64(i64 %x, i64 %y) {
88 %a = and i64 %x, %y
89 ret i64 %a
90}
91
Derek Schuff8a76b042015-11-05 17:08:11 +000092; CHECK-LABEL: or64:
Dan Gohman53828fd2015-11-23 16:50:18 +000093; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000094; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000095; CHECK-NEXT: i64.or $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000096; CHECK-NEXT: return $pop0{{$}}
Derek Schuff8a76b042015-11-05 17:08:11 +000097define i64 @or64(i64 %x, i64 %y) {
JF Bastien8f9aea02015-08-01 04:48:44 +000098 %a = or i64 %x, %y
99 ret i64 %a
100}
101
Dan Gohmane51c0582015-10-06 00:27:55 +0000102; CHECK-LABEL: xor64:
Dan Gohman53828fd2015-11-23 16:50:18 +0000103; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +0000104; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000105; CHECK-NEXT: i64.xor $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000106; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000107define i64 @xor64(i64 %x, i64 %y) {
108 %a = xor i64 %x, %y
109 ret i64 %a
110}
111
Dan Gohmane51c0582015-10-06 00:27:55 +0000112; CHECK-LABEL: shl64:
Dan Gohman53828fd2015-11-23 16:50:18 +0000113; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +0000114; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000115; CHECK-NEXT: i64.shl $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000116; CHECK-NEXT: return $pop0{{$}}
JF Bastienfda53372015-08-03 00:00:11 +0000117define i64 @shl64(i64 %x, i64 %y) {
118 %a = shl i64 %x, %y
119 ret i64 %a
120}
JF Bastien8f9aea02015-08-01 04:48:44 +0000121
Dan Gohmane51c0582015-10-06 00:27:55 +0000122; CHECK-LABEL: shr64:
Dan Gohman53828fd2015-11-23 16:50:18 +0000123; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +0000124; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000125; CHECK-NEXT: i64.shr_u $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000126; CHECK-NEXT: return $pop0{{$}}
JF Bastienfda53372015-08-03 00:00:11 +0000127define i64 @shr64(i64 %x, i64 %y) {
128 %a = lshr i64 %x, %y
129 ret i64 %a
130}
JF Bastien8f9aea02015-08-01 04:48:44 +0000131
Dan Gohmane51c0582015-10-06 00:27:55 +0000132; CHECK-LABEL: sar64:
Dan Gohman53828fd2015-11-23 16:50:18 +0000133; CHECK-NEXT: .param i64, i64{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +0000134; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000135; CHECK-NEXT: i64.shr_s $push0=, $0, $1{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000136; CHECK-NEXT: return $pop0{{$}}
JF Bastienfda53372015-08-03 00:00:11 +0000137define i64 @sar64(i64 %x, i64 %y) {
138 %a = ashr i64 %x, %y
139 ret i64 %a
140}
JF Bastien8f9aea02015-08-01 04:48:44 +0000141
Dan Gohmane51c0582015-10-06 00:27:55 +0000142; CHECK-LABEL: clz64:
143; CHECK-NEXT: .param i64{{$}}
144; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000145; CHECK-NEXT: i64.clz $push0=, $0{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000146; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000147define i64 @clz64(i64 %x) {
148 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
149 ret i64 %a
150}
151
Dan Gohmane51c0582015-10-06 00:27:55 +0000152; CHECK-LABEL: clz64_zero_undef:
153; CHECK-NEXT: .param i64{{$}}
154; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000155; CHECK-NEXT: i64.clz $push0=, $0{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000156; CHECK-NEXT: return $pop0{{$}}
Dan Gohman08fc9662015-08-24 16:39:37 +0000157define i64 @clz64_zero_undef(i64 %x) {
158 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
159 ret i64 %a
160}
161
Dan Gohmane51c0582015-10-06 00:27:55 +0000162; CHECK-LABEL: ctz64:
163; CHECK-NEXT: .param i64{{$}}
164; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000165; CHECK-NEXT: i64.ctz $push0=, $0{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000166; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000167define i64 @ctz64(i64 %x) {
168 %a = call i64 @llvm.cttz.i64(i64 %x, i1 false)
169 ret i64 %a
170}
171
Dan Gohmane51c0582015-10-06 00:27:55 +0000172; CHECK-LABEL: ctz64_zero_undef:
173; CHECK-NEXT: .param i64{{$}}
174; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000175; CHECK-NEXT: i64.ctz $push0=, $0{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000176; CHECK-NEXT: return $pop0{{$}}
Dan Gohman08fc9662015-08-24 16:39:37 +0000177define i64 @ctz64_zero_undef(i64 %x) {
178 %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
179 ret i64 %a
180}
181
Dan Gohmane51c0582015-10-06 00:27:55 +0000182; CHECK-LABEL: popcnt64:
183; CHECK-NEXT: .param i64{{$}}
184; CHECK-NEXT: .result i64{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +0000185; CHECK-NEXT: i64.popcnt $push0=, $0{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000186; CHECK-NEXT: return $pop0{{$}}
JF Bastien8f9aea02015-08-01 04:48:44 +0000187define i64 @popcnt64(i64 %x) {
188 %a = call i64 @llvm.ctpop.i64(i64 %x)
189 ret i64 %a
190}
Dan Gohmanc8d7f142016-03-21 19:54:41 +0000191
192; CHECK-LABEL: eqz64:
193; CHECK-NEXT: .param i64{{$}}
194; CHECK-NEXT: .result i32{{$}}
195; CHECK-NEXT: i64.eqz $push0=, $0{{$}}
196; CHECK-NEXT: return $pop0{{$}}
197define i32 @eqz64(i64 %x) {
198 %a = icmp eq i64 %x, 0
199 %b = zext i1 %a to i32
200 ret i32 %b
201}