blob: ff358227d987c54d8601395c08d139eeb32274ca [file] [log] [blame]
Dan Gohman7d7409e2017-02-28 23:37:04 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-explicit-locals | FileCheck %s
JF Bastien73ff6af2015-08-31 22:24:11 +00002
3; Test that truncating stores are assembled properly.
4
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00005target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman7d7409e2017-02-28 23:37:04 +00006target triple = "wasm32-unknown-unknown-wasm"
JF Bastien73ff6af2015-08-31 22:24:11 +00007
Dan Gohmane51c0582015-10-06 00:27:55 +00008; CHECK-LABEL: trunc_i8_i32:
Dan Gohman7f1bdb22016-10-06 22:08:28 +00009; CHECK: i32.store8 0($0), $1{{$}}
JF Bastien73ff6af2015-08-31 22:24:11 +000010define void @trunc_i8_i32(i8 *%p, i32 %v) {
11 %t = trunc i32 %v to i8
12 store i8 %t, i8* %p
13 ret void
14}
15
Dan Gohmane51c0582015-10-06 00:27:55 +000016; CHECK-LABEL: trunc_i16_i32:
Dan Gohman7f1bdb22016-10-06 22:08:28 +000017; CHECK: i32.store16 0($0), $1{{$}}
JF Bastien73ff6af2015-08-31 22:24:11 +000018define void @trunc_i16_i32(i16 *%p, i32 %v) {
19 %t = trunc i32 %v to i16
20 store i16 %t, i16* %p
21 ret void
22}
23
Dan Gohmane51c0582015-10-06 00:27:55 +000024; CHECK-LABEL: trunc_i8_i64:
Dan Gohman7f1bdb22016-10-06 22:08:28 +000025; CHECK: i64.store8 0($0), $1{{$}}
JF Bastien73ff6af2015-08-31 22:24:11 +000026define void @trunc_i8_i64(i8 *%p, i64 %v) {
27 %t = trunc i64 %v to i8
28 store i8 %t, i8* %p
29 ret void
30}
31
Dan Gohmane51c0582015-10-06 00:27:55 +000032; CHECK-LABEL: trunc_i16_i64:
Dan Gohman7f1bdb22016-10-06 22:08:28 +000033; CHECK: i64.store16 0($0), $1{{$}}
JF Bastien73ff6af2015-08-31 22:24:11 +000034define void @trunc_i16_i64(i16 *%p, i64 %v) {
35 %t = trunc i64 %v to i16
36 store i16 %t, i16* %p
37 ret void
38}
39
Dan Gohmane51c0582015-10-06 00:27:55 +000040; CHECK-LABEL: trunc_i32_i64:
Dan Gohman7f1bdb22016-10-06 22:08:28 +000041; CHECK: i64.store32 0($0), $1{{$}}
JF Bastien73ff6af2015-08-31 22:24:11 +000042define void @trunc_i32_i64(i32 *%p, i64 %v) {
43 %t = trunc i64 %v to i32
44 store i32 %t, i32* %p
45 ret void
46}