xref: /llvm-project/llvm/test/CodeGen/WebAssembly/PR41841.ll (revision 122b0220fd45ee71acda912b0b712bb8edb6ba46)
1; RUN: llc < %s -O0 -wasm-disable-explicit-locals -wasm-keep-registers -asm-verbose=false | FileCheck %s
2
3target triple = "wasm32-unknown-unknown"
4
5declare void @foo(i128)
6
7; CHECK-LABEL: test_zext:
8; CHECK-NEXT: .functype test_zext (i32) -> (){{$}}
9; CHECK-NEXT: i64.extend_i32_u $[[TMP3:[0-9]+]]=, $0{{$}}
10; CHECK-NEXT: i64.const $[[TMP4:[0-9]+]]=, 1{{$}}
11; CHECK-NEXT: i64.and $[[TMP1:[0-9]+]]=, $[[TMP3]], $[[TMP4]]{{$}}
12; CHECK-NEXT: i64.const $[[TMP2:[0-9]+]]=, 0{{$}}
13; CHECK-NEXT: call foo, $[[TMP1]], $[[TMP2]]{{$}}
14; CHECK-NEXT: return{{$}}
15define void @test_zext(i1 %b) nounwind {
16  %res = zext i1 %b to i128
17  br label %next
18
19next:                                             ; preds = %start
20  call void @foo(i128 %res)
21  ret void
22}
23
24; CHECK-LABEL: test_sext:
25; CHECK-NEXT:.functype test_sext (i32) -> (){{$}}
26; CHECK-NEXT: i64.extend_i32_u $[[TMP3:[0-9]+]]=, $0{{$}}
27; CHECK-NEXT: i64.const $[[TMP4:[0-9]+]]=, 1{{$}}
28; CHECK-NEXT: i64.and $[[TMP5:[0-9]+]]=, $[[TMP3]], $[[TMP4]]{{$}}
29; CHECK-NEXT: i64.const $[[TMP6:[0-9]+]]=, 0{{$}}
30; CHECK-NEXT: i64.sub $[[TMP1:[0-9]+]]=, $[[TMP6]], $[[TMP5]]{{$}}
31; CHECK-NEXT: local.copy $[[TMP2:[0-9]+]]=, $[[TMP1]]{{$}}
32; CHECK-NEXT: call foo, $[[TMP1]], $[[TMP2]]{{$}}
33; CHECK-NEXT: return{{$}}
34define void @test_sext(i1 %b) nounwind {
35  %res = sext i1 %b to i128
36  br label %next
37
38next:                                             ; preds = %start
39  call void @foo(i128 %res)
40  ret void
41}
42