1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
3 ; Test that extending loads are assembled properly.
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 ; CHECK-LABEL: sext_i8_i32:
9 ; CHECK: i32.load8_s $push0=, 0($0){{$}}
10 ; CHECK-NEXT: return $pop0{{$}}
11 define i32 @sext_i8_i32(i8 *%p) {
13 %e = sext i8 %v to i32
17 ; CHECK-LABEL: zext_i8_i32:
18 ; CHECK: i32.load8_u $push0=, 0($0){{$}}
19 ; CHECK-NEXT: return $pop0{{$}}
20 define i32 @zext_i8_i32(i8 *%p) {
22 %e = zext i8 %v to i32
26 ; CHECK-LABEL: sext_i16_i32:
27 ; CHECK: i32.load16_s $push0=, 0($0){{$}}
28 ; CHECK-NEXT: return $pop0{{$}}
29 define i32 @sext_i16_i32(i16 *%p) {
30 %v = load i16, i16* %p
31 %e = sext i16 %v to i32
35 ; CHECK-LABEL: zext_i16_i32:
36 ; CHECK: i32.load16_u $push0=, 0($0){{$}}
37 ; CHECK-NEXT: return $pop0{{$}}
38 define i32 @zext_i16_i32(i16 *%p) {
39 %v = load i16, i16* %p
40 %e = zext i16 %v to i32
44 ; CHECK-LABEL: sext_i8_i64:
45 ; CHECK: i64.load8_s $push0=, 0($0){{$}}
46 ; CHECK-NEXT: return $pop0{{$}}
47 define i64 @sext_i8_i64(i8 *%p) {
49 %e = sext i8 %v to i64
53 ; CHECK-LABEL: zext_i8_i64:
54 ; CHECK: i64.load8_u $push0=, 0($0){{$}}
55 ; CHECK-NEXT: return $pop0{{$}}
56 define i64 @zext_i8_i64(i8 *%p) {
58 %e = zext i8 %v to i64
62 ; CHECK-LABEL: sext_i16_i64:
63 ; CHECK: i64.load16_s $push0=, 0($0){{$}}
64 ; CHECK-NEXT: return $pop0{{$}}
65 define i64 @sext_i16_i64(i16 *%p) {
66 %v = load i16, i16* %p
67 %e = sext i16 %v to i64
71 ; CHECK-LABEL: zext_i16_i64:
72 ; CHECK: i64.load16_u $push0=, 0($0){{$}}
73 ; CHECK-NEXT: return $pop0{{$}}
74 define i64 @zext_i16_i64(i16 *%p) {
75 %v = load i16, i16* %p
76 %e = zext i16 %v to i64
80 ; CHECK-LABEL: sext_i32_i64:
81 ; CHECK: i64.load32_s $push0=, 0($0){{$}}
82 ; CHECK-NEXT: return $pop0{{$}}
83 define i64 @sext_i32_i64(i32 *%p) {
84 %v = load i32, i32* %p
85 %e = sext i32 %v to i64
89 ; CHECK-LABEL: zext_i32_i64:
90 ; CHECK: i64.load32_u $push0=, 0($0){{$}}
91 ; CHECK: return $pop0{{$}}
92 define i64 @zext_i32_i64(i32 *%p) {
93 %v = load i32, i32* %p
94 %e = zext i32 %v to i64