Skip to content

Commit

Permalink
Control over the support for the LSC immediate global base offset on…
Browse files Browse the repository at this point in the history
… the driver info level

This change is to add a new property to the driver info which informs if support for the LSC immediate global base offset is enabled.
  • Loading branch information
krystian-andrzejewski authored and igcbot committed Sep 15, 2023
1 parent e1e7882 commit 3fc4f58
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
3 changes: 2 additions & 1 deletion IGC/Compiler/CISACodeGen/CISABuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5048,7 +5048,8 @@ namespace IGC
SaveOption(vISA_IncSpillCostAllAddrTaken, false);
}

if (IGC_GET_FLAG_VALUE(LscImmOffsMatch) > 0) {
if ((IGC_GET_FLAG_VALUE(LscImmOffsMatch) > 0 && m_program->m_DriverInfo->supportsLSCImmediateGlobalBaseOffsetForA32()) ||
IGC_GET_FLAG_VALUE(LscImmOffsMatch) > 1) {
auto val = IGC_GET_FLAG_VALUE(LscImmOffsVisaOpts);
SaveOption(vISA_lscEnableImmOffsFor, val);
} else {
Expand Down
7 changes: 7 additions & 0 deletions IGC/Compiler/CISACodeGen/DriverInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ namespace IGC

// Specifies alignment of indirect data
virtual unsigned getCrossThreadDataAlignment() const { return 32; }

// Informs if LSC immediate global offset for A64 is supported
virtual bool supportsLSCImmediateGlobalBaseOffsetForA64() const { return true; }

// Informs if LSC immediate global offset for A32 is supported
virtual bool supportsLSCImmediateGlobalBaseOffsetForA32() const { return true; }

protected:
bool autoGRFSelection = false;
};
Expand Down
32 changes: 27 additions & 5 deletions IGC/Compiler/CISACodeGen/PatternMatchPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ IGC_INITIALIZE_PASS_END(CodeGenPatternMatch, PASS_FLAG, PASS_DESCRIPTION, PASS_C

namespace IGC
{

CodeGenPatternMatch::CodeGenPatternMatch() : FunctionPass(ID),
m_rootIsSubspanUse(false),
m_blocks(nullptr),
Expand Down Expand Up @@ -397,6 +396,15 @@ namespace IGC
ConstantPlacement[C] = LCA;
}

bool CodeGenPatternMatch::supportsLSCImmediateGlobalBaseOffset()
{
bool res = IGC_GET_FLAG_VALUE(LscImmOffsMatch) > 1 ||
(m_Platform.matchImmOffsetsLSC() &&
(m_ctx->m_DriverInfo.supportsLSCImmediateGlobalBaseOffsetForA64() ||
m_ctx->m_DriverInfo.supportsLSCImmediateGlobalBaseOffsetForA32()));
return res;
}

// Check bool values that can be emitted as a single element predicate.
void CodeGenPatternMatch::gatherUniformBools(Value* Val)
{
Expand Down Expand Up @@ -1281,7 +1289,7 @@ namespace IGC
case GenISAIntrinsic::GenISA_ldraw_indexed:
case GenISAIntrinsic::GenISA_storerawvector_indexed:
case GenISAIntrinsic::GenISA_storeraw_indexed:
match = m_Platform.matchImmOffsetsLSC() ?
match = supportsLSCImmediateGlobalBaseOffset() ?
MatchImmOffsetLSC(I) || MatchSingleInstruction(I) :
MatchSingleInstruction(I);
break;
Expand Down Expand Up @@ -1454,7 +1462,7 @@ namespace IGC
void CodeGenPatternMatch::visitStoreInst(StoreInst& I)
{
bool match = false;
if (m_Platform.matchImmOffsetsLSC()) {
if (supportsLSCImmediateGlobalBaseOffset()) {
match = MatchImmOffsetLSC(I);
if (match) return;
}
Expand All @@ -1465,7 +1473,7 @@ namespace IGC
void CodeGenPatternMatch::visitLoadInst(LoadInst& I)
{
bool match = false;
if (m_Platform.matchImmOffsetsLSC()) {
if (supportsLSCImmediateGlobalBaseOffset()) {
match = MatchImmOffsetLSC(I);
if (match)
return;
Expand Down Expand Up @@ -2609,11 +2617,25 @@ namespace IGC

llvm::Instruction *addSubInst =
llvm::dyn_cast<llvm::Instruction>(I.getOperand((unsigned)addrOpnd));
llvm::Instruction *intToPtrInst = nullptr;
if (!addSubInst) {
// e.g. the address is a constant
return false;
}

Type* addInstType = addSubInst->getType();
// Note that the A64 addressing mode can be only connected with load and store instructions
bool isA64AddressingModel = addInstType->isPointerTy() &&
IGC::isA64Ptr(cast<PointerType>(addInstType), m_ctx);

bool isSupportedCase =
(isA64AddressingModel && m_ctx->m_DriverInfo.supportsLSCImmediateGlobalBaseOffsetForA64()) ||
(!isA64AddressingModel && m_ctx->m_DriverInfo.supportsLSCImmediateGlobalBaseOffsetForA32()) ||
IGC_GET_FLAG_VALUE(LscImmOffsMatch) > 1;
if (!isSupportedCase)
{
return false;
}
llvm::Instruction* intToPtrInst = nullptr;
if (addSubInst->getOpcode() == llvm::Instruction::IntToPtr) {
intToPtrInst = addSubInst;
addSubInst = llvm::dyn_cast<llvm::Instruction>(addSubInst->getOperand(0));
Expand Down
3 changes: 3 additions & 0 deletions IGC/Compiler/CISACodeGen/PatternMatchPass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ namespace IGC
return m_WI && (m_WI->isUniform(V));
};

bool supportsLSCImmediateGlobalBaseOffset();


public:
llvm::DenseSet<llvm::Instruction*> m_usedInstructions;
bool m_rootIsSubspanUse;
Expand Down

0 comments on commit 3fc4f58

Please sign in to comment.