Skip to content

Commit 24cc26a

Browse files
scottp101sys_zuul
authored andcommitted
Handle case where we don't have an inttoptr.
Change-Id: Ifbf691a9e399c90ff4c36441c33544a91e0db08f
1 parent 4d1aab8 commit 24cc26a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -939,19 +939,22 @@ void ConstantCoalescing::CombineTwoLoads(BufChunk* cov_chunk, Instruction* load,
939939
unsigned addrSpace = (cast<PointerType>(addr_ptr->getType()))->getAddressSpace();
940940
if (addrSpace == ADDRESS_SPACE_CONSTANT)
941941
{
942-
// no GEP, OCL path
943-
IGC_ASSERT(isa<IntToPtrInst>(addr_ptr));
942+
// OCL path
943+
IGC_ASSERT(
944+
isa<IntToPtrInst>(addr_ptr) ||
945+
isa<BitCastInst>(addr_ptr) ||
946+
cast<GetElementPtrInst>(addr_ptr)->hasAllZeroIndices());
944947
Value* eac = cast<Instruction>(addr_ptr)->getOperand(0);
945948
// non-uniform, address must be non-uniform
946-
IGC_ASSERT(isa<Instruction>(eac));
947949
// modify the address calculation if the chunk-start is changed
948950
if (eltid0 != cov_chunk->chunkStart)
949951
{
950952
eac = FormChunkAddress(cov_chunk);
951953
}
952954
// new IntToPtr and new load
953955
// cannot use irbuilder to create IntToPtr. It may create ConstantExpr instead of instruction
954-
Value* ptrcast = IntToPtrInst::Create(Instruction::IntToPtr, eac, PointerType::get(vty, addrSpace), "twoScalar", load0);
956+
auto* ptrcast = CastInst::CreateBitOrPointerCast(
957+
eac, PointerType::get(vty, addrSpace), "twoScalar", load0);
955958
m_TT->RegisterNewValueAndAssignID(ptrcast);
956959
wiAns->incUpdateDepend(ptrcast, WIAnalysis::RANDOM);
957960
cov_chunk->chunkIO = irBuilder->CreateLoad(ptrcast, false);

0 commit comments

Comments
 (0)