1
1
/* ========================== begin_copyright_notice ============================
2
2
3
- Copyright (C) 2021-2024 Intel Corporation
3
+ Copyright (C) 2021-2025 Intel Corporation
4
4
5
5
SPDX-License-Identifier: MIT
6
6
@@ -1582,6 +1582,16 @@ bool Substituter::processGEP(GetElementPtrInst &GEPI,
1582
1582
unsigned PlainTyIdx = FindIt - GottenTypeArr.begin ();
1583
1583
1584
1584
if (PlainTyIdx == Size) {
1585
+ Type *PrevType = IdxPath.getTyAt (Size - 1 );
1586
+ // In case of opaque pointers, GEP's leading zero indices can be omitted and
1587
+ // in this case previous type is not a structure type
1588
+ if (!isa<StructType>(PrevType)) {
1589
+ Type *PlainType = getBaseTy (GottenTypeArr[Size - 1 ]);
1590
+ Instruction *ToInsert =
1591
+ generateNewGEPs (GEPI, *PlainType, IdxPath, NewInstr, Size - 1 );
1592
+ InstToInst.emplace_back (cast<Instruction>(&GEPI), ToInsert);
1593
+ return true ;
1594
+ }
1585
1595
// Case of FE1
1586
1596
auto InstUses = getInstUses (GEPI);
1587
1597
if (!InstUses)
@@ -1590,7 +1600,6 @@ bool Substituter::processGEP(GetElementPtrInst &GEPI,
1590
1600
1591
1601
// That means that we are getting split struct so we need to create GEPs.
1592
1602
// STyToBeSplit is the result of the instruction.
1593
- Type *PrevType = IdxPath.getTyAt (Size - 1 );
1594
1603
unsigned Idx = IdxPath.getIdxAt (Size - 1 );
1595
1604
StructType *STyToBeSplit = cast<StructType>(PrevType);
1596
1605
const ListOfSplitElements &ListOfPossibleTypes =
@@ -1621,14 +1630,18 @@ bool Substituter::processGEP(GetElementPtrInst &GEPI,
1621
1630
return false ;
1622
1631
} else {
1623
1632
Type *PrevType = IdxPath.getTyAt (PlainTyIdx);
1624
- unsigned Idx = IdxPath.getIdxAt (PlainTyIdx);
1625
- StructType *STyToBeSplit = cast<StructType>(PrevType);
1626
- IGC_ASSERT_MESSAGE (
1627
- Graph.getElementsListOfSTyAtIdx (*STyToBeSplit, Idx).size () == 1 ,
1628
- " Access to element of Struct does not get unsplit type." );
1629
1633
Type *PlainType = getBaseTy (GottenTypeArr[PlainTyIdx]);
1634
+ // In case of opaque pointers, GEP's leading zero indices can be omitted and
1635
+ // in this case previous type is not a structure type
1636
+ if (auto *STyToBeSplit = dyn_cast<StructType>(PrevType)) {
1637
+ unsigned Idx = IdxPath.getIdxAt (PlainTyIdx);
1638
+ IGC_ASSERT_MESSAGE (
1639
+ Graph.getElementsListOfSTyAtIdx (*STyToBeSplit, Idx).size () == 1 ,
1640
+ " Access to element of Struct does not get unsplit type." );
1641
+ PlainTyIdx += 1 ;
1642
+ }
1630
1643
Instruction *ToInsert =
1631
- generateNewGEPs (GEPI, *PlainType, IdxPath, NewInstr, PlainTyIdx + 1 );
1644
+ generateNewGEPs (GEPI, *PlainType, IdxPath, NewInstr, PlainTyIdx);
1632
1645
InstToInst.emplace_back (cast<Instruction>(&GEPI), ToInsert);
1633
1646
}
1634
1647
return true ;
0 commit comments