@@ -110,5 +110,71 @@ define void @splat_ptr_scatter(ptr %ptr, <4 x i1> %mask, <4 x i32> %val) {
110
110
ret void
111
111
}
112
112
113
+ define <4 x i32 > @scalar_prefix (ptr %base , i64 %index , <4 x i64 > %vecidx ) {
114
+ ; CHECK-LABEL: @scalar_prefix(
115
+ ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], i64 [[INDEX:%.*]], <4 x i64> [[VECIDX:%.*]]
116
+ ; CHECK-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[TMP2]], i32 4, <4 x i1> splat (i1 true), <4 x i32> undef)
117
+ ; CHECK-NEXT: ret <4 x i32> [[RES]]
118
+ ;
119
+ %gep = getelementptr [256 x i32 ], ptr %base , i64 %index , <4 x i64 > %vecidx
120
+ %res = call <4 x i32 > @llvm.masked.gather.v4i32.v4p0 (<4 x ptr > %gep , i32 4 , <4 x i1 > <i1 true , i1 true , i1 true , i1 true >, <4 x i32 > undef )
121
+ ret <4 x i32 > %res
122
+ }
123
+
124
+ define <4 x i32 > @scalar_prefix_with_splat (ptr %base , i64 %index , <4 x i64 > %vecidx ) {
125
+ ; CHECK-LABEL: @scalar_prefix_with_splat(
126
+ ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i64> poison, i64 [[INDEX:%.*]], i32 0
127
+ ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i64> [[BROADCAST_SPLATINSERT]], <4 x i64> poison, <4 x i32> zeroinitializer
128
+ ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], <4 x i64> [[BROADCAST_SPLAT]], <4 x i64> [[VECIDX:%.*]]
129
+ ; CHECK-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[TMP2]], i32 4, <4 x i1> splat (i1 true), <4 x i32> undef)
130
+ ; CHECK-NEXT: ret <4 x i32> [[RES]]
131
+ ;
132
+ %broadcast.splatinsert = insertelement <4 x i64 > poison, i64 %index , i32 0
133
+ %broadcast.splat = shufflevector <4 x i64 > %broadcast.splatinsert , <4 x i64 > poison, <4 x i32 > zeroinitializer
134
+
135
+ %gep = getelementptr [256 x i32 ], ptr %base , <4 x i64 > %broadcast.splat , <4 x i64 > %vecidx
136
+ %res = call <4 x i32 > @llvm.masked.gather.v4i32.v4p0 (<4 x ptr > %gep , i32 4 , <4 x i1 > <i1 true , i1 true , i1 true , i1 true >, <4 x i32 > undef )
137
+ ret <4 x i32 > %res
138
+ }
139
+
140
+ define <4 x i32 > @scalar_prefix_with_constant_splat (ptr %base , <4 x i64 > %vecidx ) {
141
+ ; CHECK-LABEL: @scalar_prefix_with_constant_splat(
142
+ ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], <4 x i64> splat (i64 20), <4 x i64> [[VECIDX:%.*]]
143
+ ; CHECK-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[TMP2]], i32 4, <4 x i1> splat (i1 true), <4 x i32> undef)
144
+ ; CHECK-NEXT: ret <4 x i32> [[RES]]
145
+ ;
146
+ %gep = getelementptr [256 x i32 ], ptr %base , <4 x i64 > splat (i64 20 ), <4 x i64 > %vecidx
147
+ %res = call <4 x i32 > @llvm.masked.gather.v4i32.v4p0 (<4 x ptr > %gep , i32 4 , <4 x i1 > <i1 true , i1 true , i1 true , i1 true >, <4 x i32 > undef )
148
+ ret <4 x i32 > %res
149
+ }
150
+
151
+ define <4 x i32 > @reassociate (ptr %base , i64 %index , <4 x i64 > %vecidx ) {
152
+ ; CHECK-LABEL: @reassociate(
153
+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], <4 x i64> [[VECIDX:%.*]], i64 [[INDEX:%.*]]
154
+ ; CHECK-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[GEP]], i32 4, <4 x i1> splat (i1 true), <4 x i32> undef)
155
+ ; CHECK-NEXT: ret <4 x i32> [[RES]]
156
+ ;
157
+ %gep = getelementptr [256 x i32 ], ptr %base , <4 x i64 > %vecidx , i64 %index
158
+ %res = call <4 x i32 > @llvm.masked.gather.v4i32.v4p0 (<4 x ptr > %gep , i32 4 , <4 x i1 > <i1 true , i1 true , i1 true , i1 true >, <4 x i32 > undef )
159
+ ret <4 x i32 > %res
160
+ }
161
+
162
+ define <4 x i32 > @reassociate_with_splat (ptr %base , i64 %index , <4 x i64 > %vecidx ) {
163
+ ; CHECK-LABEL: @reassociate_with_splat(
164
+ ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i64> poison, i64 [[INDEX:%.*]], i32 0
165
+ ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i64> [[BROADCAST_SPLATINSERT]], <4 x i64> poison, <4 x i32> zeroinitializer
166
+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], <4 x i64> [[VECIDX:%.*]], <4 x i64> [[BROADCAST_SPLAT]]
167
+ ; CHECK-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[GEP]], i32 4, <4 x i1> splat (i1 true), <4 x i32> undef)
168
+ ; CHECK-NEXT: ret <4 x i32> [[RES]]
169
+ ;
170
+ %broadcast.splatinsert = insertelement <4 x i64 > poison, i64 %index , i32 0
171
+ %broadcast.splat = shufflevector <4 x i64 > %broadcast.splatinsert , <4 x i64 > poison, <4 x i32 > zeroinitializer
172
+
173
+ %gep = getelementptr [256 x i32 ], ptr %base , <4 x i64 > %vecidx , <4 x i64 > %broadcast.splat
174
+ %res = call <4 x i32 > @llvm.masked.gather.v4i32.v4p0 (<4 x ptr > %gep , i32 4 , <4 x i1 > <i1 true , i1 true , i1 true , i1 true >, <4 x i32 > undef )
175
+ ret <4 x i32 > %res
176
+ }
177
+
178
+
113
179
declare <4 x i32 > @llvm.masked.gather.v4i32.v4p0 (<4 x ptr >, i32 , <4 x i1 >, <4 x i32 >)
114
180
declare void @llvm.masked.scatter.v4i32.v4p0 (<4 x i32 >, <4 x ptr >, i32 , <4 x i1 >)
0 commit comments