@@ -283,7 +283,7 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
283
283
break ;
284
284
}
285
285
auto *Tr = dyn_cast<FPTruncInst>(*Ext->user_begin ());
286
- if (!Tr || !Tr->getType ()->getScalarType ()-> isHalfTy ()) {
286
+ if (!Tr || !Tr->getType ()->isHalfTy ()) {
287
287
AllHalfExtracts = false ;
288
288
break ;
289
289
}
@@ -293,15 +293,13 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
293
293
294
294
if (AllHalfExtracts && !Extracts.empty ()) {
295
295
auto *VecTy = cast<VectorType>(II.getType ());
296
- unsigned NElts = VecTy->getElementCount ().getKnownMinValue ();
297
296
Type *HalfVecTy =
298
- VectorType::get (Type::getHalfTy (II.getContext ()), NElts, false );
297
+ VecTy-> getWithNewType (Type::getHalfTy (II.getContext ()));
299
298
300
299
// Obtain the original image sample intrinsic's signature
301
300
// and replace its return type with the half-vector for D16 folding
302
301
SmallVector<Type *, 8 > SigTys;
303
- if (!Intrinsic::getIntrinsicSignature (II.getCalledFunction (), SigTys))
304
- return nullptr ;
302
+ Intrinsic::getIntrinsicSignature (II.getCalledFunction (), SigTys);
305
303
SigTys[0 ] = HalfVecTy;
306
304
307
305
Module *M = II.getModule ();
@@ -311,9 +309,8 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
311
309
II.mutateType (HalfVecTy);
312
310
II.setCalledFunction (HalfDecl);
313
311
314
- IRBuilder<> Builder (&II);
315
- for (auto [lane, Ext] : enumerate(Extracts)) {
316
- FPTruncInst *Tr = Truncs[lane];
312
+ IRBuilder<> Builder (II.getContext ());
313
+ for (auto [Ext, Tr] : zip (Extracts, Truncs)) {
317
314
Value *Idx = Ext->getIndexOperand ();
318
315
319
316
Builder.SetInsertPoint (Tr);
@@ -324,9 +321,9 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
324
321
Tr->replaceAllUsesWith (HalfExtract);
325
322
}
326
323
327
- for (auto *T : Truncs)
324
+ for (FPTruncInst *T : Truncs)
328
325
IC.eraseInstFromFunction (*T);
329
- for (auto *E : Extracts)
326
+ for (ExtractElementInst *E : Extracts)
330
327
IC.eraseInstFromFunction (*E);
331
328
332
329
return &II;
0 commit comments