Skip to content

Commit 6e23c1f

Browse files
aratajewpszymich
authored andcommitted
Fix generic pointers tagging
Since Neo passes GPU addresses in a canonical form, it is possible that bits [61:63] are all set to 1. Canonical form of address is constructed in a way that bit 47. is replicated to the upper bits. So bits [48:63] may either be all zeores or all ones - it depends on bit 47. Value of bit 47 depends on how Neo manages memory address space. Whether it uses higher addresses for global memory allocation or lower addresses. It also depends on how many resources were requested by a user. According to the above, bits [61:63] can either be all zeroes or all ones. If they are all zeros, then setting a tag with a single OR operation is enough, but if they are all ones, then it is necessary to clear them with AND operation before before setting a tag with OR operation. Since IGC doesn't have an information whether a particular address has zeroes or ones on bits [61:63], AND operation must always get generated.
1 parent 5259fd6 commit 6e23c1f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8603,6 +8603,10 @@ void EmitPass::emitAddrSpaceToGenericCast(llvm::AddrSpaceCastInst* addrSpaceCast
86038603
m_encoder->Push();
86048604

86058605
// Add tag to high part
8606+
8607+
// The initial address could be in a canonical form, that means bit 47 is replicated
8608+
// to the upper bits. To set a tag, bits [61:63] must get zeroed before setting a tag with OR operation.
8609+
m_encoder->And(srcHigh, srcHigh, m_currShader->ImmToVariable(0x1fffffff, ISA_TYPE_UD));
86068610
m_encoder->Or(srcHigh, srcHigh, m_currShader->ImmToVariable(tag << 29, ISA_TYPE_UD));
86078611
m_encoder->Push();
86088612

@@ -8625,6 +8629,9 @@ void EmitPass::emitAddrSpaceToGenericCast(llvm::AddrSpaceCastInst* addrSpaceCast
86258629
numLanes(m_currShader->m_SIMDSize),
86268630
ISA_TYPE_UQ, m_currShader->getGRFAlignment(),
86278631
m_destination->IsUniform(), CName::NONE);
8632+
// The initial address could be in a canonical form, that means bit 47 is replicated
8633+
// to the upper bits. To set a tag, bits [61:63] must get zeroed before setting a tag with OR operation.
8634+
m_encoder->And(pTempVar, srcV, m_currShader->ImmToVariable(0x1fffffffffffffff, ISA_TYPE_UQ));
86288635
m_encoder->Or(pTempVar, srcV, m_currShader->ImmToVariable(static_cast<uint64_t>(tag) << 61, ISA_TYPE_UQ));
86298636
m_encoder->Cast(m_destination, pTempVar);
86308637
m_encoder->Push();

0 commit comments

Comments
 (0)