1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
3 ; Test that i1 extending loads and truncating stores are assembled properly.
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 ; CHECK-LABEL: load_u_i1_i32:
9 ; CHECK: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
10 ; CHECK-NEXT: return $pop[[NUM0]]{{$}}
11 define i32 @load_u_i1_i32(i1* %p) {
13 %e = zext i1 %v to i32
17 ; CHECK-LABEL: load_s_i1_i32:
18 ; CHECK: i32.const $push[[NUM3:[0-9]+]]=, 0{{$}}
19 ; CHECK-NEXT: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
20 ; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 1{{$}}
21 ; CHECK-NEXT: i32.and $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}}
22 ; CHECK-NEXT: i32.sub $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM2]]{{$}}
23 ; CHECK-NEXT: return $pop[[NUM4]]{{$}}
24 define i32 @load_s_i1_i32(i1* %p) {
26 %e = sext i1 %v to i32
30 ; CHECK-LABEL: load_u_i1_i64:
31 ; CHECK: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
32 ; CHECK-NEXT: return $pop[[NUM0]]{{$}}
33 define i64 @load_u_i1_i64(i1* %p) {
35 %e = zext i1 %v to i64
39 ; CHECK-LABEL: load_s_i1_i64:
40 ; CHECK: i64.const $push[[NUM3:[0-9]+]]=, 0{{$}}
41 ; CHECK-NEXT: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
42 ; CHECK-NEXT: i64.const $push[[NUM1:[0-9]+]]=, 1{{$}}
43 ; CHECK-NEXT: i64.and $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}}
44 ; CHECK-NEXT: i64.sub $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM2]]{{$}}
45 ; CHECK-NEXT: return $pop[[NUM4]]{{$}}
46 define i64 @load_s_i1_i64(i1* %p) {
48 %e = sext i1 %v to i64
52 ; CHECK-LABEL: store_i32_i1:
53 ; CHECK: i32.const $push[[NUM0:[0-9]+]]=, 1{{$}}
54 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $1, $pop[[NUM0]]{{$}}
55 ; CHECK-NEXT: i32.store8 0($0), $pop[[NUM1]]{{$}}
56 define void @store_i32_i1(i1* %p, i32 %v) {
57 %t = trunc i32 %v to i1
62 ; CHECK-LABEL: store_i64_i1:
63 ; CHECK: i64.const $push[[NUM0:[0-9]+]]=, 1{{$}}
64 ; CHECK-NEXT: i64.and $push[[NUM1:[0-9]+]]=, $1, $pop[[NUM0]]{{$}}
65 ; CHECK-NEXT: i64.store8 0($0), $pop[[NUM1]]{{$}}
66 define void @store_i64_i1(i1* %p, i64 %v) {
67 %t = trunc i64 %v to i1