@@ -1853,25 +1853,32 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s
18531853 else
18541854 {
18551855 // gfx path
1856- IGC_ASSERT (isa<IntToPtrInst>(addr_ptr));
1856+ IGC_ASSERT (isa<IntToPtrInst>(addr_ptr) || isa<BitCastInst>(addr_ptr) );
18571857 addr_ptr->mutateType (PointerType::get (vty, addrSpace));
1858+ Instruction* intToPtrInst = cast<Instruction>(addr_ptr);
1859+ while (isa<IntToPtrInst>(intToPtrInst->getOperand (0 )) ||
1860+ isa<BitCastInst>(intToPtrInst->getOperand (0 )))
1861+ {
1862+ intToPtrInst = cast<Instruction>(intToPtrInst->getOperand (0 ));
1863+ }
1864+ IGC_ASSERT (isa<IntToPtrInst>(intToPtrInst));
18581865 if (cov_chunk->baseIdxV == nullptr )
18591866 {
18601867 Value* cv_start = ConstantInt::get (irBuilder->getInt32Ty (), cov_chunk->chunkStart * cov_chunk->elementSize );
1861- cast<Instruction>(addr_ptr) ->setOperand (0 , cv_start);
1868+ intToPtrInst ->setOperand (0 , cv_start);
18621869 }
18631870 else
18641871 {
1865- Value* op = cast<Instruction>(addr_ptr)->getOperand (0 );
1866- IGC_ASSERT (isa<Instruction>(op));
1867- Instruction* eac = cast<Instruction>(op);
1872+ IGC_ASSERT (isa<Instruction>(intToPtrInst->getOperand (0 )));
1873+ Instruction* eac = cast<Instruction>(intToPtrInst->getOperand (0 ));
18681874 IGC_ASSERT (nullptr != eac);
1875+ // Has to be `Add` or `Or` instruction, see SimpleBaseOffset().
18691876 IGC_ASSERT ((eac->getOpcode () == Instruction::Add) || (eac->getOpcode () == Instruction::Or));
18701877 ConstantInt* cv_start = ConstantInt::get (irBuilder->getInt32Ty (), cov_chunk->chunkStart * cov_chunk->elementSize );
18711878 IGC_ASSERT (nullptr != cv_start);
18721879 if (cv_start->isZero ())
18731880 {
1874- cast<Instruction>(addr_ptr) ->setOperand (0 , eac->getOperand (0 ));
1881+ intToPtrInst ->setOperand (0 , eac->getOperand (0 ));
18751882 }
18761883 else
18771884 {
0 commit comments