Skip to content

Commit cc66281

Browse files
committed
[AMDGPU] Update for comments.
1 parent 567b55f commit cc66281

File tree

2 files changed

+12
-388
lines changed

2 files changed

+12
-388
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
283283
break;
284284
}
285285
auto *Tr = dyn_cast<FPTruncInst>(*Ext->user_begin());
286-
if (!Tr || !Tr->getType()->getScalarType()->isHalfTy()) {
286+
if (!Tr || !Tr->getType()->isHalfTy()) {
287287
AllHalfExtracts = false;
288288
break;
289289
}
@@ -293,15 +293,13 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
293293

294294
if (AllHalfExtracts && !Extracts.empty()) {
295295
auto *VecTy = cast<VectorType>(II.getType());
296-
unsigned NElts = VecTy->getElementCount().getKnownMinValue();
297296
Type *HalfVecTy =
298-
VectorType::get(Type::getHalfTy(II.getContext()), NElts, false);
297+
VecTy->getWithNewType(Type::getHalfTy(II.getContext()));
299298

300299
// Obtain the original image sample intrinsic's signature
301300
// and replace its return type with the half-vector for D16 folding
302301
SmallVector<Type *, 8> SigTys;
303-
if (!Intrinsic::getIntrinsicSignature(II.getCalledFunction(), SigTys))
304-
return nullptr;
302+
Intrinsic::getIntrinsicSignature(II.getCalledFunction(), SigTys);
305303
SigTys[0] = HalfVecTy;
306304

307305
Module *M = II.getModule();
@@ -311,9 +309,8 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
311309
II.mutateType(HalfVecTy);
312310
II.setCalledFunction(HalfDecl);
313311

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)) {
317314
Value *Idx = Ext->getIndexOperand();
318315

319316
Builder.SetInsertPoint(Tr);
@@ -324,9 +321,9 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
324321
Tr->replaceAllUsesWith(HalfExtract);
325322
}
326323

327-
for (auto *T : Truncs)
324+
for (FPTruncInst *T : Truncs)
328325
IC.eraseInstFromFunction(*T);
329-
for (auto *E : Extracts)
326+
for (ExtractElementInst *E : Extracts)
330327
IC.eraseInstFromFunction(*E);
331328

332329
return &II;

0 commit comments

Comments
 (0)