@@ -168,12 +168,25 @@ bool LowPrecisionOpt::propagateSamplerType(llvm::GenIntrinsicInst& I)
168
168
return false ;
169
169
}
170
170
171
- Type* eltTy = cast<VectorType>(I.getType ())->getElementType ();
171
+ Type* eltTy = NULL ;
172
+ bool isFloatType = false ;
173
+
174
+ if (I.getType ()->isVectorTy ())
175
+ {
176
+ eltTy = cast<VectorType>(I.getType ())->getElementType ();
177
+ isFloatType = cast<VectorType>(I.getType ())->getElementType ()->isFloatTy ();
178
+ }
179
+ else
180
+ {
181
+ eltTy = I.getType ();
182
+ isFloatType = I.getType ()->isFloatTy ();
183
+ }
184
+
172
185
Type* newDstType = nullptr ;
173
186
if (eltTy->isFloatingPointTy ())
174
187
{
175
188
// check that all uses are extractelement followed by fpext
176
- newDstType = cast<VectorType>(I. getType ())-> getElementType ()-> isFloatTy () ?
189
+ newDstType = isFloatType ?
177
190
m_builder->getHalfTy () : m_builder->getFloatTy ();
178
191
for (auto use = I.user_begin (); use != I.user_end (); ++use)
179
192
{
@@ -236,9 +249,15 @@ bool LowPrecisionOpt::propagateSamplerType(llvm::GenIntrinsicInst& I)
236
249
return false ;
237
250
}
238
251
239
- VectorType* oldTy = cast<VectorType>(I.getType ());
252
+ unsigned int numberOfElements = 1 ;
253
+
254
+ if (I.getType ()->isVectorTy ())
255
+ {
256
+ numberOfElements = int_cast<unsigned int >(cast<VectorType>(I.getType ())->getNumElements ());
257
+ }
258
+
240
259
llvm::SmallVector<llvm::Type*, 4 > overloadTys;
241
- auto retTy = IGCLLVM::FixedVectorType::get (newDstType, int_cast< unsigned int >(oldTy-> getNumElements ()) );
260
+ auto retTy = IGCLLVM::FixedVectorType::get (newDstType, numberOfElements );
242
261
overloadTys.push_back (retTy);
243
262
auto ID = I.getIntrinsicID ();
244
263
switch (ID)
0 commit comments