blob: 9900960496254b32c948d74ad74537d0bc46be76 [file] [log] [blame]
Wouter van Oortmerssen8a9cb242018-08-27 15:45:51 +00001; RUN: llc < %s -mtriple=wasm32 -wasm-keep-registers | FileCheck %s --check-prefixes=WASM32
Eli Friedman73e8a7842018-08-16 18:39:39 +00002; NOTE: did not compile on wasm64 at the time the test was created!
3
4define { i128, i8 } @muloti_test(i128 %l, i128 %r) unnamed_addr #0 {
5; WASM32-LABEL: muloti_test
Sam Clegg275d15e2019-02-23 00:07:39 +00006; WASM32: global.get $push18=, __stack_pointer
Eli Friedman73e8a7842018-08-16 18:39:39 +00007; WASM32: i32.const $push19=, 48
8; WASM32: i32.sub $push40=, $pop18, $pop19
Thomas Lively6a87dda2019-01-08 06:25:55 +00009; WASM32: local.tee $push39=, 5, $pop40
Sam Clegg275d15e2019-02-23 00:07:39 +000010; WASM32: global.set __stack_pointer, $pop39
Thomas Lively6a87dda2019-01-08 06:25:55 +000011; WASM32: local.get $push41=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000012; WASM32: i32.const $push22=, 32
13; WASM32: i32.add $push23=, $pop41, $pop22
Thomas Lively6a87dda2019-01-08 06:25:55 +000014; WASM32: local.get $push43=, 1
Eli Friedman73e8a7842018-08-16 18:39:39 +000015; WASM32: i64.const $push0=, 0
Thomas Lively6a87dda2019-01-08 06:25:55 +000016; WASM32: local.get $push42=, 3
Eli Friedman73e8a7842018-08-16 18:39:39 +000017; WASM32: i64.const $push38=, 0
Sam Clegg275d15e2019-02-23 00:07:39 +000018; WASM32: call __multi3, $pop23, $pop43, $pop0, $pop42, $pop38
Thomas Lively6a87dda2019-01-08 06:25:55 +000019; WASM32: local.get $push44=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000020; WASM32: i32.const $push24=, 16
21; WASM32: i32.add $push25=, $pop44, $pop24
Thomas Lively6a87dda2019-01-08 06:25:55 +000022; WASM32: local.get $push46=, 4
Eli Friedman73e8a7842018-08-16 18:39:39 +000023; WASM32: i64.const $push37=, 0
Thomas Lively6a87dda2019-01-08 06:25:55 +000024; WASM32: local.get $push45=, 1
Eli Friedman73e8a7842018-08-16 18:39:39 +000025; WASM32: i64.const $push36=, 0
Sam Clegg275d15e2019-02-23 00:07:39 +000026; WASM32: call __multi3, $pop25, $pop46, $pop37, $pop45, $pop36
Thomas Lively6a87dda2019-01-08 06:25:55 +000027; WASM32: local.get $push49=, 5
28; WASM32: local.get $push48=, 2
Eli Friedman73e8a7842018-08-16 18:39:39 +000029; WASM32: i64.const $push35=, 0
Thomas Lively6a87dda2019-01-08 06:25:55 +000030; WASM32: local.get $push47=, 3
Eli Friedman73e8a7842018-08-16 18:39:39 +000031; WASM32: i64.const $push34=, 0
Sam Clegg275d15e2019-02-23 00:07:39 +000032; WASM32: call __multi3, $pop49, $pop48, $pop35, $pop47, $pop34
Thomas Lively6a87dda2019-01-08 06:25:55 +000033; WASM32: local.get $push51=, 0
34; WASM32: local.get $push50=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000035; WASM32: i64.load $push1=, 32($pop50)
36; WASM32: i64.store 0($pop51), $pop1
Thomas Lively6a87dda2019-01-08 06:25:55 +000037; WASM32: local.get $push55=, 0
38; WASM32: local.get $push52=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000039; WASM32: i32.const $push5=, 40
40; WASM32: i32.add $push6=, $pop52, $pop5
41; WASM32: i64.load $push33=, 0($pop6)
Thomas Lively6a87dda2019-01-08 06:25:55 +000042; WASM32: local.tee $push32=, 1, $pop33
43; WASM32: local.get $push53=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000044; WASM32: i64.load $push3=, 0($pop53)
Thomas Lively6a87dda2019-01-08 06:25:55 +000045; WASM32: local.get $push54=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000046; WASM32: i64.load $push2=, 16($pop54)
47; WASM32: i64.add $push4=, $pop3, $pop2
48; WASM32: i64.add $push31=, $pop32, $pop4
Thomas Lively6a87dda2019-01-08 06:25:55 +000049; WASM32: local.tee $push30=, 3, $pop31
Eli Friedman73e8a7842018-08-16 18:39:39 +000050; WASM32: i64.store 8($pop55), $pop30
Thomas Lively6a87dda2019-01-08 06:25:55 +000051; WASM32: local.get $push62=, 0
52; WASM32: local.get $push56=, 2
Eli Friedman73e8a7842018-08-16 18:39:39 +000053; WASM32: i64.const $push29=, 0
54; WASM32: i64.ne $push8=, $pop56, $pop29
Thomas Lively6a87dda2019-01-08 06:25:55 +000055; WASM32: local.get $push57=, 4
Eli Friedman73e8a7842018-08-16 18:39:39 +000056; WASM32: i64.const $push28=, 0
57; WASM32: i64.ne $push7=, $pop57, $pop28
58; WASM32: i32.and $push9=, $pop8, $pop7
Thomas Lively6a87dda2019-01-08 06:25:55 +000059; WASM32: local.get $push58=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000060; WASM32: i64.load $push10=, 8($pop58)
61; WASM32: i64.const $push27=, 0
62; WASM32: i64.ne $push11=, $pop10, $pop27
63; WASM32: i32.or $push12=, $pop9, $pop11
Thomas Lively6a87dda2019-01-08 06:25:55 +000064; WASM32: local.get $push59=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000065; WASM32: i64.load $push13=, 24($pop59)
66; WASM32: i64.const $push26=, 0
67; WASM32: i64.ne $push14=, $pop13, $pop26
68; WASM32: i32.or $push15=, $pop12, $pop14
Thomas Lively6a87dda2019-01-08 06:25:55 +000069; WASM32: local.get $push61=, 3
70; WASM32: local.get $push60=, 1
Eli Friedman73e8a7842018-08-16 18:39:39 +000071; WASM32: i64.lt_u $push16=, $pop61, $pop60
72; WASM32: i32.or $push17=, $pop15, $pop16
73; WASM32: i32.store8 16($pop62), $pop17
Thomas Lively6a87dda2019-01-08 06:25:55 +000074; WASM32: local.get $push63=, 5
Eli Friedman73e8a7842018-08-16 18:39:39 +000075; WASM32: i32.const $push20=, 48
76; WASM32: i32.add $push21=, $pop63, $pop20
Sam Clegg275d15e2019-02-23 00:07:39 +000077; WASM32: global.set __stack_pointer, $pop21
Eli Friedman73e8a7842018-08-16 18:39:39 +000078
79start:
80 %0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %l, i128 %r) #2
81 %1 = extractvalue { i128, i1 } %0, 0
82 %2 = extractvalue { i128, i1 } %0, 1
83 %3 = zext i1 %2 to i8
84 %4 = insertvalue { i128, i8 } undef, i128 %1, 0
85 %5 = insertvalue { i128, i8 } %4, i8 %3, 1
86 ret { i128, i8 } %5
87}
88
89; Function Attrs: nounwind readnone speculatable
90declare { i128, i1 } @llvm.umul.with.overflow.i128(i128, i128) #1
91
92attributes #0 = { nounwind readnone uwtable }
93attributes #1 = { nounwind readnone speculatable }
94attributes #2 = { nounwind }