Skip to content

Commit 125603e

Browse files
eternastudentoigcbot
authored andcommitted
Revert "[IGC Performance][IGC]: Preprocess vector bitcasts to enable memory operations simplification."
This reverts commit a3b0a66933d6297c8aca4badc4e877558c4be7c2.
1 parent 51b1bef commit 125603e

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,6 @@ static void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSi
651651
mpm.add(createSplitIndirectEEtoSelPass());
652652
}
653653

654-
// Preprocess vector bitcasts to enable memory operations simplification.
655-
mpm.add(createVectorBitCastOptPass());
656654
// Split big vector & 3-element load/store, etc.
657655
mpm.add(createVectorPreProcessPass());
658656

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ void CustomSafeOptPass::visitCallInst(CallInst& C)
473473
break;
474474
}
475475

476+
case GenISAIntrinsic::GenISA_ldrawvector_indexed:
477+
{
478+
visitLdRawVec(inst);
479+
break;
480+
}
481+
476482
default:
477483
break;
478484
}
@@ -1339,6 +1345,56 @@ void IGC::CustomSafeOptPass::visitLdptr(llvm::CallInst* inst)
13391345
}
13401346
}
13411347

1348+
1349+
void IGC::CustomSafeOptPass::visitLdRawVec(llvm::CallInst* inst)
1350+
{
1351+
//Try to optimize and remove vector ld raw and change to scalar ld raw
1352+
1353+
//%a = call <4 x float> @llvm.genx.GenISA.ldrawvector.indexed.v4f32.p1441792f32(
1354+
//.....float addrspace(1441792) * %243, i32 %offset, i32 4, i1 false), !dbg !216
1355+
//%b = extractelement <4 x float> % 245, i32 0, !dbg !216
1356+
1357+
//into
1358+
1359+
//%new_offset = add i32 %offset, 0, !dbg !216
1360+
//%b = call float @llvm.genx.GenISA.ldraw.indexed.f32.p1441792f32.i32.i32.i1(
1361+
//.....float addrspace(1441792) * %251, i32 %new_offset, i32 4, i1 false)
1362+
1363+
if (inst->hasOneUse() &&
1364+
isa<ExtractElementInst>(inst->user_back()))
1365+
{
1366+
auto EE = cast<ExtractElementInst>(inst->user_back());
1367+
if (auto constIndex = dyn_cast<ConstantInt>(EE->getIndexOperand()))
1368+
{
1369+
llvm::IRBuilder<> builder(inst);
1370+
1371+
llvm::SmallVector<llvm::Type*, 2> ovldtypes{
1372+
EE->getType(), //float type
1373+
inst->getOperand(0)->getType(),
1374+
};
1375+
1376+
// For new_offset we need to take into acount the index of the Extract
1377+
// and convert it to bytes and add it to the existing offset
1378+
auto new_offset = constIndex->getZExtValue() * 4;
1379+
1380+
llvm::SmallVector<llvm::Value*, 4> new_args{
1381+
inst->getOperand(0),
1382+
builder.CreateAdd(inst->getOperand(1),builder.getInt32((unsigned)new_offset)),
1383+
inst->getOperand(2),
1384+
inst->getOperand(3)
1385+
};
1386+
1387+
Function* pLdraw_indexed_intrinsic = llvm::GenISAIntrinsic::getDeclaration(
1388+
inst->getModule(),
1389+
GenISAIntrinsic::GenISA_ldraw_indexed,
1390+
ovldtypes);
1391+
1392+
llvm::Value* ldraw_indexed = builder.CreateCall(pLdraw_indexed_intrinsic, new_args, "");
1393+
EE->replaceAllUsesWith(ldraw_indexed);
1394+
}
1395+
}
1396+
}
1397+
13421398
void IGC::CustomSafeOptPass::visitSampleBptr(llvm::SampleIntrinsic* sampleInst)
13431399
{
13441400
// sampleB with bias_value==0 -> sample

IGC/Compiler/CustomSafeOptPass.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace IGC
8080
void visitFPTruncInst(llvm::FPTruncInst& I);
8181
void visitExtractElementInst(llvm::ExtractElementInst& I);
8282
void visitLdptr(llvm::CallInst* inst);
83+
void visitLdRawVec(llvm::CallInst* inst);
8384
void visitLoadInst(llvm::LoadInst& I);
8485
void dp4WithIdentityMatrix(llvm::ExtractElementInst& I);
8586
bool isIdentityMatrix(llvm::ExtractElementInst& I);

0 commit comments

Comments
 (0)