@@ -1853,25 +1853,32 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s
1853
1853
else
1854
1854
{
1855
1855
// gfx path
1856
- IGC_ASSERT (isa<IntToPtrInst>(addr_ptr));
1856
+ IGC_ASSERT (isa<IntToPtrInst>(addr_ptr) || isa<BitCastInst>(addr_ptr) );
1857
1857
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));
1858
1865
if (cov_chunk->baseIdxV == nullptr )
1859
1866
{
1860
1867
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);
1862
1869
}
1863
1870
else
1864
1871
{
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 ));
1868
1874
IGC_ASSERT (nullptr != eac);
1875
+ // Has to be `Add` or `Or` instruction, see SimpleBaseOffset().
1869
1876
IGC_ASSERT ((eac->getOpcode () == Instruction::Add) || (eac->getOpcode () == Instruction::Or));
1870
1877
ConstantInt* cv_start = ConstantInt::get (irBuilder->getInt32Ty (), cov_chunk->chunkStart * cov_chunk->elementSize );
1871
1878
IGC_ASSERT (nullptr != cv_start);
1872
1879
if (cv_start->isZero ())
1873
1880
{
1874
- cast<Instruction>(addr_ptr) ->setOperand (0 , eac->getOperand (0 ));
1881
+ intToPtrInst ->setOperand (0 , eac->getOperand (0 ));
1875
1882
}
1876
1883
else
1877
1884
{
0 commit comments