1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine %s -S | FileCheck %s
4 define ptr @vector_splat_indices_v2i64_ext0(ptr %a) {
5 ; CHECK-LABEL: @vector_splat_indices_v2i64_ext0(
6 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 16
7 ; CHECK-NEXT: ret ptr [[RES]]
9 %gep = getelementptr i32, ptr %a, <2 x i64> <i64 4, i64 4>
10 %res = extractelement <2 x ptr> %gep, i32 0
14 define ptr @vector_splat_indices_nxv2i64_ext0(ptr %a) {
15 ; CHECK-LABEL: @vector_splat_indices_nxv2i64_ext0(
16 ; CHECK-NEXT: [[RES:%.*]] = getelementptr inbounds i8, ptr [[A:%.*]], i64 16
17 ; CHECK-NEXT: ret ptr [[RES]]
19 %tmp = insertelement <vscale x 2 x i64> poison, i64 4, i32 0
20 %splatof4 = shufflevector <vscale x 2 x i64> %tmp, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
21 %gep = getelementptr inbounds i32, ptr %a, <vscale x 2 x i64> %splatof4
22 %res = extractelement <vscale x 2 x ptr> %gep, i32 0
26 define ptr @vector_indices_v2i64_ext0(ptr %a, <2 x i64> %indices) {
27 ; CHECK-LABEL: @vector_indices_v2i64_ext0(
28 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[INDICES:%.*]], i64 0
29 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i32, ptr [[A:%.*]], i64 [[TMP1]]
30 ; CHECK-NEXT: ret ptr [[RES]]
32 %gep = getelementptr i32, ptr %a, <2 x i64> %indices
33 %res = extractelement <2 x ptr> %gep, i32 0
37 define ptr @vector_indices_nxv1i64_ext0(ptr %a, <vscale x 1 x i64> %indices) {
38 ; CHECK-LABEL: @vector_indices_nxv1i64_ext0(
39 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 1 x i64> [[INDICES:%.*]], i64 0
40 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i32, ptr [[A:%.*]], i64 [[TMP1]]
41 ; CHECK-NEXT: ret ptr [[RES]]
43 %gep = getelementptr i32, ptr %a, <vscale x 1 x i64> %indices
44 %res = extractelement <vscale x 1 x ptr> %gep, i32 0
49 define ptr @vector_splat_ptrs_v2i64_ext0(ptr %a, i64 %index) {
50 ; CHECK-LABEL: @vector_splat_ptrs_v2i64_ext0(
51 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i32, ptr [[A:%.*]], i64 [[INDEX:%.*]]
52 ; CHECK-NEXT: ret ptr [[RES]]
54 %tmp = insertelement <2 x ptr> poison, ptr %a, i32 0
55 %splatofa = shufflevector <2 x ptr> %tmp, <2 x ptr> poison, <2 x i32> zeroinitializer
56 %gep = getelementptr i32, <2 x ptr> %splatofa, i64 %index
57 %res = extractelement <2 x ptr> %gep, i32 0
62 define ptr @vector_splat_ptrs_nxv2i64_ext0(ptr %a, i64 %index) {
63 ; CHECK-LABEL: @vector_splat_ptrs_nxv2i64_ext0(
64 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i32, ptr [[A:%.*]], i64 [[INDEX:%.*]]
65 ; CHECK-NEXT: ret ptr [[RES]]
67 %tmp = insertelement <vscale x 2 x ptr> poison, ptr %a, i32 0
68 %splatofa = shufflevector <vscale x 2 x ptr> %tmp, <vscale x 2 x ptr> poison, <vscale x 2 x i32> zeroinitializer
69 %gep = getelementptr i32, <vscale x 2 x ptr> %splatofa, i64 %index
70 %res = extractelement <vscale x 2 x ptr> %gep, i32 0
75 define ptr @vector_struct1_splat_indices_v4i64_ext1(ptr %a) {
76 ; CHECK-LABEL: @vector_struct1_splat_indices_v4i64_ext1(
77 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 32
78 ; CHECK-NEXT: ret ptr [[RES]]
80 %gep = getelementptr {float, float}, ptr %a, <4 x i32> <i32 4, i32 4, i32 4, i32 4>, i32 0
81 %res = extractelement <4 x ptr> %gep, i32 1
86 define ptr @vector_struct2_splat_indices_v4i64_ext1(ptr %a) {
87 ; CHECK-LABEL: @vector_struct2_splat_indices_v4i64_ext1(
88 ; CHECK-NEXT: [[RES:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 92
89 ; CHECK-NEXT: ret ptr [[RES]]
91 %gep = getelementptr {float, [8 x float]}, ptr %a, i32 2, i32 1, <4 x i32> <i32 4, i32 4, i32 4, i32 4>
92 %res = extractelement <4 x ptr> %gep, i32 1
99 define ptr @vector_indices_nxv2i64_ext3(ptr %a, <vscale x 2 x i64> %indices) {
100 ; CHECK-LABEL: @vector_indices_nxv2i64_ext3(
101 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[A:%.*]], <vscale x 2 x i64> [[INDICES:%.*]]
102 ; CHECK-NEXT: [[RES:%.*]] = extractelement <vscale x 2 x ptr> [[GEP]], i64 3
103 ; CHECK-NEXT: ret ptr [[RES]]
105 %gep = getelementptr i32, ptr %a, <vscale x 2 x i64> %indices
106 %res = extractelement <vscale x 2 x ptr> %gep, i32 3
110 define ptr @vector_indices_nxv2i64_extN(ptr %a, <vscale x 2 x i64> %indices, i32 %N) {
111 ; CHECK-LABEL: @vector_indices_nxv2i64_extN(
112 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[A:%.*]], <vscale x 2 x i64> [[INDICES:%.*]]
113 ; CHECK-NEXT: [[RES:%.*]] = extractelement <vscale x 2 x ptr> [[GEP]], i32 [[N:%.*]]
114 ; CHECK-NEXT: ret ptr [[RES]]
116 %gep = getelementptr i32, ptr %a, <vscale x 2 x i64> %indices
117 %res = extractelement <vscale x 2 x ptr> %gep, i32 %N
121 define void @vector_indices_nxv2i64_mulitple_use(ptr %a, <vscale x 2 x i64> %indices, ptr %b, ptr %c) {
122 ; CHECK-LABEL: @vector_indices_nxv2i64_mulitple_use(
123 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[A:%.*]], <vscale x 2 x i64> [[INDICES:%.*]]
124 ; CHECK-NEXT: [[LANE0:%.*]] = extractelement <vscale x 2 x ptr> [[GEP]], i64 0
125 ; CHECK-NEXT: [[LANE1:%.*]] = extractelement <vscale x 2 x ptr> [[GEP]], i64 1
126 ; CHECK-NEXT: store ptr [[LANE0]], ptr [[B:%.*]], align 8
127 ; CHECK-NEXT: store ptr [[LANE1]], ptr [[C:%.*]], align 8
128 ; CHECK-NEXT: ret void
130 %gep = getelementptr i32, ptr %a, <vscale x 2 x i64> %indices
131 %lane0 = extractelement <vscale x 2 x ptr> %gep, i32 0
132 %lane1 = extractelement <vscale x 2 x ptr> %gep, i32 1
133 store ptr %lane0, ptr %b, align 8
134 store ptr %lane1, ptr %c, align 8
138 define ptr @vector_ptrs_and_indices_ext0(<vscale x 4 x ptr> %a, <vscale x 4 x i64> %indices) {
139 ; CHECK-LABEL: @vector_ptrs_and_indices_ext0(
140 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, <vscale x 4 x ptr> [[A:%.*]], <vscale x 4 x i64> [[INDICES:%.*]]
141 ; CHECK-NEXT: [[RES:%.*]] = extractelement <vscale x 4 x ptr> [[GEP]], i64 0
142 ; CHECK-NEXT: ret ptr [[RES]]
144 %gep = getelementptr i32, <vscale x 4 x ptr> %a, <vscale x 4 x i64> %indices
145 %res = extractelement <vscale x 4 x ptr> %gep, i32 0