• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
4target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
5target triple = "wasm32-unknown-unknown"
6
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]]{{$}}
11
12; NOSIGNEXT-LABEL: i32_extend8_s
13; NOSIGNEXT-NOT: i32.extend8_s
14define i32 @i32_extend8_s(i8 %x) {
15  %a = sext i8 %x to i32
16  ret i32 %a
17}
18
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]]{{$}}
23
24; NOSIGNEXT-LABEL: i32_extend16_s
25; NOSIGNEXT-NOT: i32.extend16_s
26define i32 @i32_extend16_s(i16 %x) {
27  %a = sext i16 %x to i32
28  ret i32 %a
29}
30
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]]{{$}}
36
37; NOSIGNEXT-LABEL: i64_extend8_s
38; NOSIGNEXT-NOT: i64.extend8_s
39define i64 @i64_extend8_s(i8 %x) {
40  %a = sext i8 %x to i64
41  ret i64 %a
42}
43
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]]{{$}}
49
50; NOSIGNEXT-LABEL: i64_extend16_s
51; NOSIGNEXT-NOT: i16.extend16_s
52define i64 @i64_extend16_s(i16 %x) {
53  %a = sext i16 %x to i64
54  ret i64 %a
55}
56
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]]{{$}}
62define i64 @i64_extend32_s(i32 %x) {
63  %a = sext i32 %x to i64
64  ret i64 %a
65}
66
67