2016-05-21 08:21:56 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
|
2015-09-01 06:24:11 +08:00
|
|
|
|
|
|
|
; Test that i1 extending loads and truncating stores are assembled properly.
|
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2015-09-01 06:24:11 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: load_u_i1_i32:
|
2015-12-05 08:26:39 +08:00
|
|
|
; CHECK: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
|
2015-11-26 00:55:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM0]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define i32 @load_u_i1_i32(i1* %p) {
|
2015-09-01 06:24:11 +08:00
|
|
|
%v = load i1, i1* %p
|
|
|
|
%e = zext i1 %v to i32
|
|
|
|
ret i32 %e
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: load_s_i1_i32:
|
2016-01-20 00:59:23 +08:00
|
|
|
; CHECK: i32.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
|
|
|
|
; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 31{{$}}
|
|
|
|
; CHECK-NEXT: shl $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}}
|
|
|
|
; CHECK-NEXT: i32.const $push[[NUM4:[0-9]+]]=, 31{{$}}
|
|
|
|
; CHECK-NEXT: shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM4]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM3]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define i32 @load_s_i1_i32(i1* %p) {
|
2015-09-01 06:24:11 +08:00
|
|
|
%v = load i1, i1* %p
|
|
|
|
%e = sext i1 %v to i32
|
|
|
|
ret i32 %e
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: load_u_i1_i64:
|
2015-12-05 08:26:39 +08:00
|
|
|
; CHECK: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
|
2015-11-26 00:55:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM0]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define i64 @load_u_i1_i64(i1* %p) {
|
2015-09-01 06:24:11 +08:00
|
|
|
%v = load i1, i1* %p
|
|
|
|
%e = zext i1 %v to i64
|
|
|
|
ret i64 %e
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: load_s_i1_i64:
|
2016-01-20 00:59:23 +08:00
|
|
|
; CHECK: i64.load8_u $push[[NUM0:[0-9]+]]=, 0($0){{$}}
|
|
|
|
; CHECK-NEXT: i64.const $push[[NUM1:[0-9]+]]=, 63{{$}}
|
|
|
|
; CHECK-NEXT: shl $push[[NUM2:[0-9]+]]=, $pop[[NUM0]], $pop[[NUM1]]{{$}}
|
|
|
|
; CHECK-NEXT: i64.const $push[[NUM4:[0-9]+]]=, 63{{$}}
|
|
|
|
; CHECK-NEXT: shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM4]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM3]]{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define i64 @load_s_i1_i64(i1* %p) {
|
2015-09-01 06:24:11 +08:00
|
|
|
%v = load i1, i1* %p
|
|
|
|
%e = sext i1 %v to i64
|
|
|
|
ret i64 %e
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: store_i32_i1:
|
2015-11-24 05:55:57 +08:00
|
|
|
; CHECK: i32.const $push[[NUM0:[0-9]+]]=, 1{{$}}
|
|
|
|
; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $1, $pop[[NUM0]]{{$}}
|
2016-05-18 07:19:03 +08:00
|
|
|
; CHECK-NEXT: i32.store8 $drop=, 0($0), $pop[[NUM1]]{{$}}
|
2015-09-01 06:24:11 +08:00
|
|
|
define void @store_i32_i1(i1* %p, i32 %v) {
|
|
|
|
%t = trunc i32 %v to i1
|
|
|
|
store i1 %t, i1* %p
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: store_i64_i1:
|
2015-11-24 05:55:57 +08:00
|
|
|
; CHECK: i64.const $push[[NUM0:[0-9]+]]=, 1{{$}}
|
|
|
|
; CHECK-NEXT: i64.and $push[[NUM1:[0-9]+]]=, $1, $pop[[NUM0]]{{$}}
|
2016-05-18 07:19:03 +08:00
|
|
|
; CHECK-NEXT: i64.store8 $drop=, 0($0), $pop[[NUM1]]{{$}}
|
2015-09-01 06:24:11 +08:00
|
|
|
define void @store_i64_i1(i1* %p, i64 %v) {
|
|
|
|
%t = trunc i64 %v to i1
|
|
|
|
store i1 %t, i1* %p
|
|
|
|
ret void
|
|
|
|
}
|