1 ; RUN: llc < %s -mattr=+atomics,+sign-ext -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s 2 3 ; Test that extending loads are assembled properly. 4 5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 6 target triple = "wasm32-unknown-unknown" 7 8 ; CHECK-LABEL: sext_i8_i32: 9 ; CHECK: i32.atomic.load8_u $push0=, 0($0){{$}} 10 ; CHECK-NEXT: i32.extend8_s $push1=, $pop0{{$}} 11 ; CHECK-NEXT: return $pop1{{$}} 12 define i32 @sext_i8_i32(i8 *%p) { 13 %v = load atomic i8, i8* %p seq_cst, align 1 14 %e = sext i8 %v to i32 15 ret i32 %e 16 } 17 18 ; CHECK-LABEL: zext_i8_i32: 19 ; CHECK: i32.atomic.load8_u $push0=, 0($0){{$}} 20 ; CHECK-NEXT: return $pop0{{$}} 21 define i32 @zext_i8_i32(i8 *%p) { 22 e1: 23 %v = load atomic i8, i8* %p seq_cst, align 1 24 %e = zext i8 %v to i32 25 ret i32 %e 26 } 27 28 ; CHECK-LABEL: sext_i16_i32: 29 ; CHECK: i32.atomic.load16_u $push0=, 0($0){{$}} 30 ; CHECK-NEXT: i32.extend16_s $push1=, $pop0{{$}} 31 ; CHECK-NEXT: return $pop1{{$}} 32 define i32 @sext_i16_i32(i16 *%p) { 33 %v = load atomic i16, i16* %p seq_cst, align 2 34 %e = sext i16 %v to i32 35 ret i32 %e 36 } 37 38 ; CHECK-LABEL: zext_i16_i32: 39 ; CHECK: i32.atomic.load16_u $push0=, 0($0){{$}} 40 ; CHECK-NEXT: return $pop0{{$}} 41 define i32 @zext_i16_i32(i16 *%p) { 42 %v = load atomic i16, i16* %p seq_cst, align 2 43 %e = zext i16 %v to i32 44 ret i32 %e 45 } 46 47 ; CHECK-LABEL: sext_i8_i64: 48 ; CHECK: i64.atomic.load8_u $push0=, 0($0){{$}} 49 ; CHECK: i64.extend8_s $push1=, $pop0{{$}} 50 ; CHECK-NEXT: return $pop1{{$}} 51 define i64 @sext_i8_i64(i8 *%p) { 52 %v = load atomic i8, i8* %p seq_cst, align 1 53 %e = sext i8 %v to i64 54 ret i64 %e 55 } 56 57 ; CHECK-LABEL: zext_i8_i64: 58 ; CHECK: i64.atomic.load8_u $push0=, 0($0){{$}} 59 ; CHECK-NEXT: return $pop0{{$}} 60 define i64 @zext_i8_i64(i8 *%p) { 61 %v = load atomic i8, i8* %p seq_cst, align 1 62 %e = zext i8 %v to i64 63 ret i64 %e 64 } 65 66 ; CHECK-LABEL: sext_i16_i64: 67 ; CHECK: i64.atomic.load16_u $push0=, 0($0){{$}} 68 ; CHECK: i64.extend16_s $push1=, $pop0{{$}} 69 ; CHECK-NEXT: return $pop1{{$}} 70 define i64 @sext_i16_i64(i16 *%p) { 71 %v = load atomic i16, i16* %p seq_cst, align 2 72 %e = sext i16 %v to i64 73 ret i64 %e 74 } 75 76 ; CHECK-LABEL: zext_i16_i64: 77 ; CHECK: i64.atomic.load16_u $push0=, 0($0){{$}} 78 ; CHECK-NEXT: return $pop0{{$}} 79 define i64 @zext_i16_i64(i16 *%p) { 80 %v = load atomic i16, i16* %p seq_cst, align 2 81 %e = zext i16 %v to i64 82 ret i64 %e 83 } 84 85 ; CHECK-LABEL: sext_i32_i64: 86 ; CHECK: i32.atomic.load $push0=, 0($0){{$}} 87 ; CHECK: i64.extend_s/i32 $push1=, $pop0{{$}} 88 ; CHECK-NEXT: return $pop1{{$}} 89 define i64 @sext_i32_i64(i32 *%p) { 90 %v = load atomic i32, i32* %p seq_cst, align 4 91 %e = sext i32 %v to i64 92 ret i64 %e 93 } 94 95 ; CHECK-LABEL: zext_i32_i64: 96 ; CHECK: i64.atomic.load32_u $push0=, 0($0){{$}} 97 ; CHECK: return $pop0{{$}} 98 define i64 @zext_i32_i64(i32 *%p) { 99 %v = load atomic i32, i32* %p seq_cst, align 4 100 %e = zext i32 %v to i64 101 ret i64 %e 102 } 103