1 ; RUN: opt -S -instcombine < %s | FileCheck %s
3 target triple = "aarch64-unknown-linux-gnu"
5 ; op2 = tbl(op1 dup_x(idx)) -> op2 = vector_splat(extractelement(op1, idx))
7 define <vscale x 16 x i8> @dup_ext_i8(<vscale x 16 x i8> %data) #0 {
8 ; CHECK-LABEL: @dup_ext_i8(
9 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 16 x i8> [[DATA:%.*]], i8 1
10 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 16 x i8> poison, i8 [[TMP1]], i32 0
11 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 16 x i8> [[DOTSPLATINSERT]], <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
12 ; CHECK-NEXT: ret <vscale x 16 x i8> [[DOTSPLAT]]
14 %tmp = call <vscale x 16 x i8> @llvm.aarch64.sve.dup.x.nxv16i8(i8 1)
15 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.tbl.nxv16i8(<vscale x 16 x i8> %data, <vscale x 16 x i8> %tmp)
16 ret <vscale x 16 x i8> %out
19 define <vscale x 8 x i16> @dup_ext_i16(<vscale x 8 x i16> %data) #0 {
20 ; CHECK-LABEL: @dup_ext_i16(
21 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 8 x i16> [[DATA:%.*]], i16 1
22 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 8 x i16> poison, i16 [[TMP1]], i32 0
23 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 8 x i16> [[DOTSPLATINSERT]], <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
24 ; CHECK-NEXT: ret <vscale x 8 x i16> [[DOTSPLAT]]
26 %tmp = call <vscale x 8 x i16> @llvm.aarch64.sve.dup.x.nxv8i16(i16 1)
27 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.tbl.nxv8i16(<vscale x 8 x i16> %data, <vscale x 8 x i16> %tmp)
28 ret <vscale x 8 x i16> %out
31 define <vscale x 4 x i32> @dup_ext_i32(<vscale x 4 x i32> %data) #0 {
32 ; CHECK-LABEL: @dup_ext_i32(
33 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 4 x i32> [[DATA:%.*]], i32 1
34 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[TMP1]], i32 0
35 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[DOTSPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
36 ; CHECK-NEXT: ret <vscale x 4 x i32> [[DOTSPLAT]]
38 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.dup.x.nxv4i32(i32 1)
39 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.tbl.nxv4i32(<vscale x 4 x i32> %data, <vscale x 4 x i32> %tmp)
40 ret <vscale x 4 x i32> %out
43 define <vscale x 2 x i64> @dup_ext_i64(<vscale x 2 x i64> %data) #0 {
44 ; CHECK-LABEL: @dup_ext_i64(
45 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 2 x i64> [[DATA:%.*]], i64 1
46 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP1]], i32 0
47 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[DOTSPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
48 ; CHECK-NEXT: ret <vscale x 2 x i64> [[DOTSPLAT]]
50 %tmp = call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 1)
51 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.tbl.nxv2i64(<vscale x 2 x i64> %data, <vscale x 2 x i64> %tmp)
52 ret <vscale x 2 x i64> %out
55 define <vscale x 8 x half> @dup_ext_f16(<vscale x 8 x half> %data) #0 {
56 ; CHECK-LABEL: @dup_ext_f16(
57 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 8 x half> [[DATA:%.*]], i16 1
58 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 8 x half> poison, half [[TMP1]], i32 0
59 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 8 x half> [[DOTSPLATINSERT]], <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
60 ; CHECK-NEXT: ret <vscale x 8 x half> [[DOTSPLAT]]
62 %tmp = call <vscale x 8 x i16> @llvm.aarch64.sve.dup.x.nxv8i16(i16 1)
63 %out = call <vscale x 8 x half> @llvm.aarch64.sve.tbl.nxv8f16(<vscale x 8 x half> %data, <vscale x 8 x i16> %tmp)
64 ret <vscale x 8 x half> %out
67 define <vscale x 4 x float> @dup_ext_f32(<vscale x 4 x float> %data) #0 {
68 ; CHECK-LABEL: @dup_ext_f32(
69 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 4 x float> [[DATA:%.*]], i32 1
70 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1]], i32 0
71 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 4 x float> [[DOTSPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
72 ; CHECK-NEXT: ret <vscale x 4 x float> [[DOTSPLAT]]
74 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.dup.x.nxv4i32(i32 1)
75 %out = call <vscale x 4 x float> @llvm.aarch64.sve.tbl.nxv4f32(<vscale x 4 x float> %data, <vscale x 4 x i32> %tmp)
76 ret <vscale x 4 x float> %out
79 define <vscale x 2 x double> @dup_ext_f64(<vscale x 2 x double> %data) #0 {
80 ; CHECK-LABEL: @dup_ext_f64(
81 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 2 x double> [[DATA:%.*]], i64 1
82 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 2 x double> poison, double [[TMP1]], i32 0
83 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 2 x double> [[DOTSPLATINSERT]], <vscale x 2 x double> poison, <vscale x 2 x i32> zeroinitializer
84 ; CHECK-NEXT: ret <vscale x 2 x double> [[DOTSPLAT]]
86 %tmp = call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 1)
87 %out = call <vscale x 2 x double> @llvm.aarch64.sve.tbl.nxv2f64(<vscale x 2 x double> %data, <vscale x 2 x i64> %tmp)
88 ret <vscale x 2 x double> %out
91 declare <vscale x 16 x i8> @llvm.aarch64.sve.dup.x.nxv16i8( i8)
92 declare <vscale x 8 x i16> @llvm.aarch64.sve.dup.x.nxv8i16(i16)
93 declare <vscale x 4 x i32> @llvm.aarch64.sve.dup.x.nxv4i32(i32)
94 declare <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64)
95 declare <vscale x 16 x i8> @llvm.aarch64.sve.tbl.nxv16i8( <vscale x 16 x i8>, <vscale x 16 x i8>)
96 declare <vscale x 8 x i16> @llvm.aarch64.sve.tbl.nxv8i16( <vscale x 8 x i16>, <vscale x 8 x i16>)
97 declare <vscale x 4 x i32> @llvm.aarch64.sve.tbl.nxv4i32( <vscale x 4 x i32>, <vscale x 4 x i32>)
98 declare <vscale x 2 x i64> @llvm.aarch64.sve.tbl.nxv2i64( <vscale x 2 x i64>, <vscale x 2 x i64>)
99 declare <vscale x 8 x half> @llvm.aarch64.sve.tbl.nxv8f16( <vscale x 8 x half>, <vscale x 8 x i16>)
100 declare <vscale x 4 x float> @llvm.aarch64.sve.tbl.nxv4f32( <vscale x 4 x float>, <vscale x 4 x i32>)
101 declare <vscale x 2 x double> @llvm.aarch64.sve.tbl.nxv2f64( <vscale x 2 x double>, <vscale x 2 x i64>)
103 attributes #0 = { "target-features"="+sve" }