1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s 2 3 ; Test that i1 extending loads and truncating stores are assembled properly. 4 5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 6 target triple = "wasm32-unknown-unknown" 7 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) { 12 %v = load i1, i1* %p 13 %e = zext i1 %v to i32 14 ret i32 %e 15 } 16 17 ; CHECK-LABEL: load_s_i1_i32: 18 ; CHECK: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}} 19 ; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 31{{$}} 20 ; CHECK-NEXT: shl $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}} 21 ; CHECK-NEXT: i32.const $push[[NUM4:[0-9]+]]=, 31{{$}} 22 ; CHECK-NEXT: shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM4]]{{$}} 23 ; CHECK-NEXT: return $pop[[NUM3]]{{$}} 24 define i32 @load_s_i1_i32(i1* %p) { 25 %v = load i1, i1* %p 26 %e = sext i1 %v to i32 27 ret i32 %e 28 } 29 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) { 34 %v = load i1, i1* %p 35 %e = zext i1 %v to i64 36 ret i64 %e 37 } 38 39 ; CHECK-LABEL: load_s_i1_i64: 40 ; CHECK: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}} 41 ; CHECK-NEXT: i64.const $push[[NUM1:[0-9]+]]=, 63{{$}} 42 ; CHECK-NEXT: shl $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}} 43 ; CHECK-NEXT: i64.const $push[[NUM4:[0-9]+]]=, 63{{$}} 44 ; CHECK-NEXT: shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM4]]{{$}} 45 ; CHECK-NEXT: return $pop[[NUM3]]{{$}} 46 define i64 @load_s_i1_i64(i1* %p) { 47 %v = load i1, i1* %p 48 %e = sext i1 %v to i64 49 ret i64 %e 50 } 51 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 $drop=, 0($0), $pop[[NUM1]]{{$}} 56 define void @store_i32_i1(i1* %p, i32 %v) { 57 %t = trunc i32 %v to i1 58 store i1 %t, i1* %p 59 ret void 60 } 61 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 $drop=, 0($0), $pop[[NUM1]]{{$}} 66 define void @store_i64_i1(i1* %p, i64 %v) { 67 %t = trunc i64 %v to i1 68 store i1 %t, i1* %p 69 ret void 70 } 71