1 ; RUN: llc < %s -mattr=+sign-ext -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
2 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s --check-prefix=NOSIGNEXT
4 target triple = "wasm32-unknown-unknown"
6 ; CHECK-LABEL: i32_extend8_s:
7 ; CHECK-NEXT: .functype i32_extend8_s (i32) -> (i32){{$}}
8 ; CHECK-NEXT: i32.extend8_s $push[[NUM:[0-9]+]]=, $0{{$}}
9 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
11 ; NOSIGNEXT-LABEL: i32_extend8_s
12 ; NOSIGNEXT-NOT: i32.extend8_s
13 define i32 @i32_extend8_s(i8 %x) {
14 %a = sext i8 %x to i32
18 ; CHECK-LABEL: i32_extend16_s:
19 ; CHECK-NEXT: .functype i32_extend16_s (i32) -> (i32){{$}}
20 ; CHECK-NEXT: i32.extend16_s $push[[NUM:[0-9]+]]=, $0{{$}}
21 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
23 ; NOSIGNEXT-LABEL: i32_extend16_s
24 ; NOSIGNEXT-NOT: i32.extend16_s
25 define i32 @i32_extend16_s(i16 %x) {
26 %a = sext i16 %x to i32
30 ; CHECK-LABEL: i64_extend8_s:
31 ; CHECK-NEXT: .functype i64_extend8_s (i32) -> (i64){{$}}
32 ; CHECK-NEXT: i64.extend_i32_u $push[[NUM1:[0-9]+]]=, $0{{$}}
33 ; CHECK-NEXT: i64.extend8_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]]{{$}}
34 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
36 ; NOSIGNEXT-LABEL: i64_extend8_s
37 ; NOSIGNEXT-NOT: i64.extend8_s
38 define i64 @i64_extend8_s(i8 %x) {
39 %a = sext i8 %x to i64
43 ; CHECK-LABEL: i64_extend16_s:
44 ; CHECK-NEXT: .functype i64_extend16_s (i32) -> (i64){{$}}
45 ; CHECK-NEXT: i64.extend_i32_u $push[[NUM1:[0-9]+]]=, $0{{$}}
46 ; CHECK-NEXT: i64.extend16_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]]{{$}}
47 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
49 ; NOSIGNEXT-LABEL: i64_extend16_s
50 ; NOSIGNEXT-NOT: i16.extend16_s
51 define i64 @i64_extend16_s(i16 %x) {
52 %a = sext i16 %x to i64
56 ; No SIGN_EXTEND_INREG is needed for 32->64 extension.
57 ; CHECK-LABEL: i64_extend32_s:
58 ; CHECK-NEXT: .functype i64_extend32_s (i32) -> (i64){{$}}
59 ; CHECK-NEXT: i64.extend_i32_s $push[[NUM:[0-9]+]]=, $0{{$}}
60 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
61 define i64 @i64_extend32_s(i32 %x) {
62 %a = sext i32 %x to i64