xref: /llvm-project/llvm/test/CodeGen/WebAssembly/simd-load-splat.ll (revision f841ad30d77eeb4c51663e68efefdb734c7a3d07)
1; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+simd128 | FileCheck %s
2
3; Regression test for an ISel failure when a splatted load had more
4; than one use. The main tests for load_splat are in simd-offset.ll.
5
6target triple = "wasm32-unknown-unknown"
7
8; CHECK-LABEL: load_splat:
9; CHECK-NEXT: .functype load_splat (i32, i32) -> (i32)
10; CHECK-NEXT: i32.load8_u $push[[E:[0-9]+]]=, 0($0){{$}}
11; CHECK-NEXT: local.tee $push[[T:[0-9]+]]=, $[[R:[0-9]+]]=, $pop[[E]]{{$}}
12; CHECK-NEXT: i8x16.splat $push[[V:[0-9]+]]=, $pop[[T]]{{$}}
13; CHECK-NEXT: v128.store 0($1), $pop[[V]]{{$}}
14; CHECK-NEXT: return $[[R]]{{$}}
15define i8 @load_splat(ptr %p, ptr %out) {
16  %e = load i8, ptr %p
17  %v1 = insertelement <16 x i8> undef, i8 %e, i32 0
18  %v2 = shufflevector <16 x i8> %v1, <16 x i8> undef, <16 x i32> zeroinitializer
19  store <16 x i8> %v2, ptr %out
20  ret i8 %e
21}
22