xref: /llvm-project/llvm/test/CodeGen/WebAssembly/store-trunc.ll (revision 73856247eef35f5336e485dc009842a5b991c421)
1; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
2; RUN: llc < %s --mtriple=wasm64-unknown-unknown -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
3
4; Test that truncating stores are assembled properly.
5
6; CHECK-LABEL: trunc_i8_i32:
7; CHECK: i32.store8 0($0), $1{{$}}
8define void @trunc_i8_i32(ptr %p, i32 %v) {
9  %t = trunc i32 %v to i8
10  store i8 %t, ptr %p
11  ret void
12}
13
14; CHECK-LABEL: trunc_i16_i32:
15; CHECK: i32.store16 0($0), $1{{$}}
16define void @trunc_i16_i32(ptr %p, i32 %v) {
17  %t = trunc i32 %v to i16
18  store i16 %t, ptr %p
19  ret void
20}
21
22; CHECK-LABEL: trunc_i8_i64:
23; CHECK: i64.store8 0($0), $1{{$}}
24define void @trunc_i8_i64(ptr %p, i64 %v) {
25  %t = trunc i64 %v to i8
26  store i8 %t, ptr %p
27  ret void
28}
29
30; CHECK-LABEL: trunc_i16_i64:
31; CHECK: i64.store16 0($0), $1{{$}}
32define void @trunc_i16_i64(ptr %p, i64 %v) {
33  %t = trunc i64 %v to i16
34  store i16 %t, ptr %p
35  ret void
36}
37
38; CHECK-LABEL: trunc_i32_i64:
39; CHECK: i64.store32 0($0), $1{{$}}
40define void @trunc_i32_i64(ptr %p, i64 %v) {
41  %t = trunc i64 %v to i32
42  store i32 %t, ptr %p
43  ret void
44}
45