1 ; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
2 ; RUN: llc < %s --mtriple=wasm64-unknown-unknown -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
4 ; Test that i1 extending loads and truncating stores are assembled properly.
6 ; CHECK-LABEL: load_u_i1_i32:
7 ; CHECK: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
8 ; CHECK-NEXT: return $pop[[NUM0]]{{$}}
9 define i32 @load_u_i1_i32(ptr %p) {
11 %e = zext i1 %v to i32
15 ; CHECK-LABEL: load_s_i1_i32:
16 ; CHECK: i32.const $push[[NUM3:[0-9]+]]=, 0{{$}}
17 ; CHECK-NEXT: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
18 ; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 1{{$}}
19 ; CHECK-NEXT: i32.and $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}}
20 ; CHECK-NEXT: i32.sub $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM2]]{{$}}
21 ; CHECK-NEXT: return $pop[[NUM4]]{{$}}
22 define i32 @load_s_i1_i32(ptr %p) {
24 %e = sext i1 %v to i32
28 ; CHECK-LABEL: load_u_i1_i64:
29 ; CHECK: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
30 ; CHECK-NEXT: return $pop[[NUM0]]{{$}}
31 define i64 @load_u_i1_i64(ptr %p) {
33 %e = zext i1 %v to i64
37 ; CHECK-LABEL: load_s_i1_i64:
38 ; CHECK: i64.const $push[[NUM3:[0-9]+]]=, 0{{$}}
39 ; CHECK-NEXT: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
40 ; CHECK-NEXT: i64.const $push[[NUM1:[0-9]+]]=, 1{{$}}
41 ; CHECK-NEXT: i64.and $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}}
42 ; CHECK-NEXT: i64.sub $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM2]]{{$}}
43 ; CHECK-NEXT: return $pop[[NUM4]]{{$}}
44 define i64 @load_s_i1_i64(ptr %p) {
46 %e = sext i1 %v to i64
50 ; CHECK-LABEL: store_i32_i1:
51 ; CHECK: i32.const $push[[NUM0:[0-9]+]]=, 1{{$}}
52 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $1, $pop[[NUM0]]{{$}}
53 ; CHECK-NEXT: i32.store8 0($0), $pop[[NUM1]]{{$}}
54 define void @store_i32_i1(ptr %p, i32 %v) {
55 %t = trunc i32 %v to i1
60 ; CHECK-LABEL: store_i64_i1:
61 ; CHECK: i64.const $push[[NUM0:[0-9]+]]=, 1{{$}}
62 ; CHECK-NEXT: i64.and $push[[NUM1:[0-9]+]]=, $1, $pop[[NUM0]]{{$}}
63 ; CHECK-NEXT: i64.store8 0($0), $pop[[NUM1]]{{$}}
64 define void @store_i64_i1(ptr %p, i64 %v) {
65 %t = trunc i64 %v to i1