Skip to content

Commit 8661d26

Browse files
Anton Sidorenkoigcbot
authored andcommitted
Fix the assignment of BTI values in the case of multiple uses
This fixes dpc++ matrix_transpose test
1 parent 68ada0e commit 8661d26

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMKernelArgOffset.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,24 +504,22 @@ void CMKernelArgOffset::processKernelOnOCLRT(MDNode *Node, Function *F) {
504504
Type *ArgTy = Arg.getType();
505505
if (ArgTy->isPointerTy()) {
506506
SmallVector<Instruction *, 8> ToErase;
507-
508-
IGC_ASSERT_MESSAGE(Arg.hasOneUse(), "invalid surface input");
509-
auto ArgUse = Arg.use_begin()->getUser();
510-
IGC_ASSERT_MESSAGE(isa<PtrToIntInst>(ArgUse),
511-
"invalid surface input usage");
512-
ToErase.push_back(cast<Instruction>(ArgUse));
513-
514-
for (auto ui = ArgUse->use_begin(), ue = ArgUse->use_end(); ui != ue;
515-
++ui) {
516-
auto User = cast<Instruction>(ui->getUser());
517-
User->replaceAllUsesWith(
518-
ConstantInt::get(User->getType(), BTI));
519-
ToErase.push_back(User);
507+
for (Use &U : Arg.uses()) {
508+
auto ArgUse = U.getUser();
509+
IGC_ASSERT_MESSAGE(isa<PtrToIntInst>(ArgUse),
510+
"invalid surface input usage");
511+
512+
std::transform(ArgUse->user_begin(), ArgUse->user_end(),
513+
std::back_inserter(ToErase), [BTI](User *U) {
514+
U->replaceAllUsesWith(
515+
ConstantInt::get(U->getType(), BTI));
516+
return cast<Instruction>(U);
517+
});
518+
ToErase.push_back(cast<Instruction>(ArgUse));
520519
}
520+
std::for_each(ToErase.begin(), ToErase.end(),
521+
[](Instruction *I) { I->eraseFromParent(); });
521522

522-
for (auto i = ToErase.rbegin(), e = ToErase.rend(); i != e; ++i)
523-
(*i)->eraseFromParent();
524-
ToErase.clear();
525523
} else {
526524
auto BTIConstant = ConstantInt::get(ArgTy, BTI);
527525
// If the number of uses for this arg more than 1 it's better to

0 commit comments

Comments
 (0)