blob: 81214dbbadb23587596106c7ca28bbd1b93807f1 [file] [log] [blame]
JF Bastien73ff6af2015-08-31 22:24:11 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test that truncating stores are assembled properly.
4
Dan Gohman5e066842015-09-09 20:54:31 +00005target datalayout = "e-p:32:32-i64:64-n32:64-S128"
JF Bastien73ff6af2015-08-31 22:24:11 +00006target triple = "wasm32-unknown-unknown"
7
Dan Gohmane51c0582015-10-06 00:27:55 +00008; CHECK-LABEL: trunc_i8_i32:
Hans Wennborg7384a2d2015-11-12 14:37:56 +00009; CHECK: i32.store8 (get_local 3), (get_local 2){{$}}
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:
Hans Wennborg7384a2d2015-11-12 14:37:56 +000017; CHECK: i32.store16 (get_local 3), (get_local 2){{$}}
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:
Hans Wennborg7384a2d2015-11-12 14:37:56 +000025; CHECK: i64.store8 (get_local 3), (get_local 2){{$}}
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:
Hans Wennborg7384a2d2015-11-12 14:37:56 +000033; CHECK: i64.store16 (get_local 3), (get_local 2){{$}}
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:
Hans Wennborg7384a2d2015-11-12 14:37:56 +000041; CHECK: i64.store32 (get_local 3), (get_local 2){{$}}
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}