xref: /llvm-project/llvm/test/CodeGen/WebAssembly/return-int32.ll (revision 41080b2fdd4b6c57d5a2926d6157b9847342b3a1)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -wasm-keep-registers | FileCheck %s
3; RUN: llc < %s -wasm-keep-registers -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=FAST
4
5target triple = "wasm32-unknown-unknown"
6
7define i32 @return_i32(i32 %p) {
8; CHECK-LABEL: return_i32:
9; CHECK:         .functype return_i32 (i32) -> (i32)
10; CHECK-NEXT:  # %bb.0:
11; CHECK-NEXT:    local.get $push0=, 0
12; CHECK-NEXT:    # fallthrough-return
13;
14; FAST-LABEL: return_i32:
15; FAST:         .functype return_i32 (i32) -> (i32)
16; FAST-NEXT:  # %bb.0:
17; FAST-NEXT:    local.get $push0=, 0
18; FAST-NEXT:    # fallthrough-return
19  ret i32 %p
20}
21
22define i32 @return_i32_twice(i32 %a) {
23; CHECK-LABEL: return_i32_twice:
24; CHECK:         .functype return_i32_twice (i32) -> (i32)
25; CHECK-NEXT:  # %bb.0:
26; CHECK-NEXT:    block
27; CHECK-NEXT:    local.get $push6=, 0
28; CHECK-NEXT:    i32.eqz $push7=, $pop6
29; CHECK-NEXT:    br_if 0, $pop7 # 0: down to label0
30; CHECK-NEXT:  # %bb.1: # %true
31; CHECK-NEXT:    i32.const $push3=, 0
32; CHECK-NEXT:    i32.const $push5=, 0
33; CHECK-NEXT:    i32.store 0($pop3), $pop5
34; CHECK-NEXT:    i32.const $push4=, 1
35; CHECK-NEXT:    return $pop4
36; CHECK-NEXT:  .LBB1_2: # %false
37; CHECK-NEXT:    end_block # label0:
38; CHECK-NEXT:    i32.const $push1=, 0
39; CHECK-NEXT:    i32.const $push0=, 2
40; CHECK-NEXT:    i32.store 0($pop1), $pop0
41; CHECK-NEXT:    i32.const $push2=, 3
42; CHECK-NEXT:    # fallthrough-return
43;
44; FAST-LABEL: return_i32_twice:
45; FAST:         .functype return_i32_twice (i32) -> (i32)
46; FAST-NEXT:  # %bb.0:
47; FAST-NEXT:    block
48; FAST-NEXT:    local.get $push6=, 0
49; FAST-NEXT:    i32.eqz $push7=, $pop6
50; FAST-NEXT:    br_if 0, $pop7 # 0: down to label0
51; FAST-NEXT:  # %bb.1: # %true
52; FAST-NEXT:    i32.const $push4=, 0
53; FAST-NEXT:    i32.const $push5=, 0
54; FAST-NEXT:    i32.store 0($pop4), $pop5
55; FAST-NEXT:    i32.const $push3=, 1
56; FAST-NEXT:    return $pop3
57; FAST-NEXT:  .LBB1_2: # %false
58; FAST-NEXT:    end_block # label0:
59; FAST-NEXT:    i32.const $push1=, 0
60; FAST-NEXT:    i32.const $push2=, 2
61; FAST-NEXT:    i32.store 0($pop1), $pop2
62; FAST-NEXT:    i32.const $push0=, 3
63; FAST-NEXT:    # fallthrough-return
64  %b = icmp ne i32 %a, 0
65  br i1 %b, label %true, label %false
66
67true:
68  store i32 0, ptr null
69  ret i32 1
70
71false:
72  store i32 2, ptr null
73  ret i32 3
74}
75