1*0d7286a6SThomas Lively; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s
2*0d7286a6SThomas Lively
3*0d7286a6SThomas Lively; Test that SIMD shifts can be lowered correctly even with shift
4*0d7286a6SThomas Lively; values that are more complex than plain splats.
5*0d7286a6SThomas Lively
6*0d7286a6SThomas Livelytarget datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7*0d7286a6SThomas Livelytarget triple = "wasm32-unknown-unknown"
8*0d7286a6SThomas Lively
9*0d7286a6SThomas Lively;; TODO: Optimize this further by scalarizing the add
10*0d7286a6SThomas Lively
11*0d7286a6SThomas Lively; CHECK-LABEL: shl_add:
12*0d7286a6SThomas Lively; CHECK-NEXT: .functype shl_add (v128, i32, i32) -> (v128)
13*0d7286a6SThomas Lively; CHECK-NEXT: i8x16.splat $push1=, $1
14*0d7286a6SThomas Lively; CHECK-NEXT: i8x16.splat $push0=, $2
15*0d7286a6SThomas Lively; CHECK-NEXT: i8x16.add $push2=, $pop1, $pop0
16*0d7286a6SThomas Lively; CHECK-NEXT: i8x16.extract_lane_u $push3=, $pop2, 0
17*0d7286a6SThomas Lively; CHECK-NEXT: i8x16.shl $push4=, $0, $pop3
18*0d7286a6SThomas Lively; CHECK-NEXT: return $pop4
19*0d7286a6SThomas Livelydefine <16 x i8> @shl_add(<16 x i8> %v, i8 %a, i8 %b) {
20*0d7286a6SThomas Lively  %t1 = insertelement <16 x i8> undef, i8 %a, i32 0
21*0d7286a6SThomas Lively  %va = shufflevector <16 x i8> %t1, <16 x i8> undef, <16 x i32> zeroinitializer
22*0d7286a6SThomas Lively  %t2 = insertelement <16 x i8> undef, i8 %b, i32 0
23*0d7286a6SThomas Lively  %vb = shufflevector <16 x i8> %t2, <16 x i8> undef, <16 x i32> zeroinitializer
24*0d7286a6SThomas Lively  %shift = add <16 x i8> %va, %vb
25*0d7286a6SThomas Lively  %r = shl <16 x i8> %v, %shift
26*0d7286a6SThomas Lively  ret <16 x i8> %r
27*0d7286a6SThomas Lively}
28