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 datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
5 target triple = "wasm32-unknown-unknown"
7 ; CHECK-LABEL: i32_extend8_s:
8 ; CHECK-NEXT: .functype i32_extend8_s (i32) -> (i32){{$}}
9 ; CHECK-NEXT: i32.extend8_s $push[[NUM:[0-9]+]]=, $0{{$}}
10 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
12 ; NOSIGNEXT-LABEL: i32_extend8_s
13 ; NOSIGNEXT-NOT: i32.extend8_s
14 define i32 @i32_extend8_s(i8 %x) {
15 %a = sext i8 %x to i32
19 ; CHECK-LABEL: i32_extend16_s:
20 ; CHECK-NEXT: .functype i32_extend16_s (i32) -> (i32){{$}}
21 ; CHECK-NEXT: i32.extend16_s $push[[NUM:[0-9]+]]=, $0{{$}}
22 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
24 ; NOSIGNEXT-LABEL: i32_extend16_s
25 ; NOSIGNEXT-NOT: i32.extend16_s
26 define i32 @i32_extend16_s(i16 %x) {
27 %a = sext i16 %x to i32
31 ; CHECK-LABEL: i64_extend8_s:
32 ; CHECK-NEXT: .functype i64_extend8_s (i32) -> (i64){{$}}
33 ; CHECK-NEXT: i64.extend_i32_u $push[[NUM1:[0-9]+]]=, $0{{$}}
34 ; CHECK-NEXT: i64.extend8_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]]{{$}}
35 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
37 ; NOSIGNEXT-LABEL: i64_extend8_s
38 ; NOSIGNEXT-NOT: i64.extend8_s
39 define i64 @i64_extend8_s(i8 %x) {
40 %a = sext i8 %x to i64
44 ; CHECK-LABEL: i64_extend16_s:
45 ; CHECK-NEXT: .functype i64_extend16_s (i32) -> (i64){{$}}
46 ; CHECK-NEXT: i64.extend_i32_u $push[[NUM1:[0-9]+]]=, $0{{$}}
47 ; CHECK-NEXT: i64.extend16_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]]{{$}}
48 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
50 ; NOSIGNEXT-LABEL: i64_extend16_s
51 ; NOSIGNEXT-NOT: i16.extend16_s
52 define i64 @i64_extend16_s(i16 %x) {
53 %a = sext i16 %x to i64
57 ; No SIGN_EXTEND_INREG is needed for 32->64 extension.
58 ; CHECK-LABEL: i64_extend32_s:
59 ; CHECK-NEXT: .functype i64_extend32_s (i32) -> (i64){{$}}
60 ; CHECK-NEXT: i64.extend_i32_s $push[[NUM:[0-9]+]]=, $0{{$}}
61 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
62 define i64 @i64_extend32_s(i32 %x) {
63 %a = sext i32 %x to i64