1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s 2 3 ; Test that i1 extending loads and truncating stores are assembled properly. 4 5 target datalayout = "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.const $[[NUM1:[0-9]+]]=, 31{{$}} 19 ; CHECK-NEXT: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}} 20 ; CHECK-NEXT: shl $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $[[NUM1]]{{$}} 21 ; CHECK-NEXT: shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $[[NUM1]]{{$}} 22 ; CHECK-NEXT: return $pop[[NUM3]]{{$}} 23 define i32 @load_s_i1_i32(i1* %p) { 24 %v = load i1, i1* %p 25 %e = sext i1 %v to i32 26 ret i32 %e 27 } 28 29 ; CHECK-LABEL: load_u_i1_i64: 30 ; CHECK: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}} 31 ; CHECK-NEXT: return $pop[[NUM0]]{{$}} 32 define i64 @load_u_i1_i64(i1* %p) { 33 %v = load i1, i1* %p 34 %e = zext i1 %v to i64 35 ret i64 %e 36 } 37 38 ; CHECK-LABEL: load_s_i1_i64: 39 ; CHECK: i64.const $[[NUM1:[0-9]+]]=, 63{{$}} 40 ; CHECK-NEXT: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}} 41 ; CHECK-NEXT: shl $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $[[NUM1]]{{$}} 42 ; CHECK-NEXT: shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $[[NUM1]]{{$}} 43 ; CHECK-NEXT: return $pop[[NUM3]]{{$}} 44 define i64 @load_s_i1_i64(i1* %p) { 45 %v = load i1, i1* %p 46 %e = sext i1 %v to i64 47 ret i64 %e 48 } 49 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 $discard=, 0($0), $pop[[NUM1]]{{$}} 54 define void @store_i32_i1(i1* %p, i32 %v) { 55 %t = trunc i32 %v to i1 56 store i1 %t, i1* %p 57 ret void 58 } 59 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 $discard=, 0($0), $pop[[NUM1]]{{$}} 64 define void @store_i64_i1(i1* %p, i64 %v) { 65 %t = trunc i64 %v to i1 66 store i1 %t, i1* %p 67 ret void 68 } 69