1 ; RUN: llc < %s -mattr=+sign-ext -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s 2 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s --check-prefix=NOSIGNEXT 3 4 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 5 target triple = "wasm32-unknown-unknown" 6 7 ; CHECK-LABEL: i32_extend8_s: 8 ; CHECK-NEXT: .param i32{{$}} 9 ; CHECK-NEXT: .result i32{{$}} 10 ; CHECK-NEXT: i32.extend8_s $push[[NUM:[0-9]+]]=, $0{{$}} 11 ; CHECK-NEXT: return $pop[[NUM]]{{$}} 12 13 ; NOSIGNEXT-LABEL: i32_extend8_s 14 ; NOSIGNEXT-NOT: i32.extend8_s 15 define i32 @i32_extend8_s(i8 %x) { 16 %a = sext i8 %x to i32 17 ret i32 %a 18 } 19 20 ; CHECK-LABEL: i32_extend16_s: 21 ; CHECK-NEXT: .param i32{{$}} 22 ; CHECK-NEXT: .result i32{{$}} 23 ; CHECK-NEXT: i32.extend16_s $push[[NUM:[0-9]+]]=, $0{{$}} 24 ; CHECK-NEXT: return $pop[[NUM]]{{$}} 25 26 ; NOSIGNEXT-LABEL: i32_extend16_s 27 ; NOSIGNEXT-NOT: i32.extend16_s 28 define i32 @i32_extend16_s(i16 %x) { 29 %a = sext i16 %x to i32 30 ret i32 %a 31 } 32 33 ; CHECK-LABEL: i64_extend8_s: 34 ; CHECK-NEXT: .param i32{{$}} 35 ; CHECK-NEXT: .result i64{{$}} 36 ; CHECK-NEXT: i64.extend_u/i32 $push[[NUM1:[0-9]+]]=, $0{{$}} 37 ; CHECK-NEXT: i64.extend8_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]]{{$}} 38 ; CHECK-NEXT: return $pop[[NUM2]]{{$}} 39 40 ; NOSIGNEXT-LABEL: i64_extend8_s 41 ; NOSIGNEXT-NOT: i64.extend8_s 42 define i64 @i64_extend8_s(i8 %x) { 43 %a = sext i8 %x to i64 44 ret i64 %a 45 } 46 47 ; CHECK-LABEL: i64_extend16_s: 48 ; CHECK-NEXT: .param i32{{$}} 49 ; CHECK-NEXT: .result i64{{$}} 50 ; CHECK-NEXT: i64.extend_u/i32 $push[[NUM1:[0-9]+]]=, $0{{$}} 51 ; CHECK-NEXT: i64.extend16_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]]{{$}} 52 ; CHECK-NEXT: return $pop[[NUM2]]{{$}} 53 54 ; NOSIGNEXT-LABEL: i64_extend16_s 55 ; NOSIGNEXT-NOT: i16.extend16_s 56 define i64 @i64_extend16_s(i16 %x) { 57 %a = sext i16 %x to i64 58 ret i64 %a 59 } 60 61 ; No SIGN_EXTEND_INREG is needed for 32->64 extension. 62 ; CHECK-LABEL: i64_extend32_s: 63 ; CHECK-NEXT: .param i32{{$}} 64 ; CHECK-NEXT: .result i64{{$}} 65 ; CHECK-NEXT: i64.extend_s/i32 $push[[NUM:[0-9]+]]=, $0{{$}} 66 ; CHECK-NEXT: return $pop[[NUM]]{{$}} 67 define i64 @i64_extend32_s(i32 %x) { 68 %a = sext i32 %x to i64 69 ret i64 %a 70 } 71 72