xref: /llvm-project/llvm/test/CodeGen/WebAssembly/umulo-i64.ll (revision 41080b2fdd4b6c57d5a2926d6157b9847342b3a1)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
3; Test that UMULO works correctly on 64-bit operands.
4target triple = "wasm32-unknown-unknown"
5
6; Function Attrs: inlinehint
7define void @"_ZN4core3num21_$LT$impl$u20$u64$GT$15overflowing_mul17h07be88b4cbac028fE"(i64, i64) unnamed_addr #0 {
8; CHECK-LABEL: _ZN4core3num21_$LT$impl$u20$u64$GT$15overflowing_mul17h07be88b4cbac028fE:
9; CHECK:         .functype _ZN4core3num21_$LT$impl$u20$u64$GT$15overflowing_mul17h07be88b4cbac028fE (i64, i64) -> ()
10; CHECK-NEXT:  # %bb.0: # %start
11; CHECK-NEXT:    global.get $push2=, __stack_pointer
12; CHECK-NEXT:    i32.const $push3=, 16
13; CHECK-NEXT:    i32.sub $push6=, $pop2, $pop3
14; CHECK-NEXT:    local.tee $push5=, $2=, $pop6
15; CHECK-NEXT:    global.set __stack_pointer, $pop5
16; CHECK-NEXT:    i64.const $push0=, 0
17; CHECK-NEXT:    i64.const $push4=, 0
18; CHECK-NEXT:    call __multi3, $2, $0, $pop0, $1, $pop4
19; CHECK-NEXT:    i64.load $push1=, 0($2)
20; CHECK-NEXT:    i64.store 0($2), $pop1
21; CHECK-NEXT:    unreachable
22start:
23  %2 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %0, i64 %1)
24  %3 = extractvalue { i64, i1 } %2, 0
25  store i64 %3, ptr undef
26  unreachable
27}
28
29; Function Attrs: nounwind readnone speculatable
30declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1
31
32attributes #0 = { inlinehint }
33attributes #1 = { nounwind readnone speculatable }
34
35define i1 @wut(i64, i64) {
36; CHECK-LABEL: wut:
37; CHECK:         .functype wut (i64, i64) -> (i32)
38; CHECK-NEXT:  # %bb.0: # %start
39; CHECK-NEXT:    global.get $push2=, __stack_pointer
40; CHECK-NEXT:    i32.const $push3=, 16
41; CHECK-NEXT:    i32.sub $push9=, $pop2, $pop3
42; CHECK-NEXT:    local.tee $push8=, $2=, $pop9
43; CHECK-NEXT:    global.set __stack_pointer, $pop8
44; CHECK-NEXT:    i64.const $push0=, 0
45; CHECK-NEXT:    i64.const $push7=, 0
46; CHECK-NEXT:    call __multi3, $2, $0, $pop0, $1, $pop7
47; CHECK-NEXT:    i64.load $1=, 8($2)
48; CHECK-NEXT:    i32.const $push4=, 16
49; CHECK-NEXT:    i32.add $push5=, $2, $pop4
50; CHECK-NEXT:    global.set __stack_pointer, $pop5
51; CHECK-NEXT:    i64.const $push6=, 0
52; CHECK-NEXT:    i64.ne $push1=, $1, $pop6
53; CHECK-NEXT:    # fallthrough-return
54start:
55  %2 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %0, i64 %1)
56  %3 = extractvalue { i64, i1 } %2, 1
57  ret i1 %3
58}
59