@@ -172,6 +172,7 @@ bool genx::loadNonSimpleConstants(
172
172
continue ;
173
173
ConstantLoader CL (C, Subtarget, DL, Inst, AddedInstructions);
174
174
if (CL.needFixingSimple ()) {
175
+ Modified = true ;
175
176
CL.fixSimple (i);
176
177
continue ;
177
178
}
@@ -773,7 +774,7 @@ bool genx::loadPhiConstants(Function &F, DominatorTree *DT,
773
774
Value *Load = nullptr ;
774
775
Instruction *InsertBefore = InsertBB->getTerminator ();
775
776
if (!CL.isSimple ())
776
- Load = CL.loadNonSimple (InsertBefore);
777
+ Load = CL.loadBig (InsertBefore);
777
778
else
778
779
Load = CL.load (InsertBefore);
779
780
Modified = true ;
@@ -852,6 +853,7 @@ bool genx::isReplicatedConstantVector(
852
853
}
853
854
854
855
void ConstantLoader::fixSimple (int OperandIdx) {
856
+ IGC_ASSERT_MESSAGE (User, " user must be provided" );
855
857
IGC_ASSERT_MESSAGE (NewC, " no need to fix simple case" );
856
858
IGC_ASSERT_MESSAGE (User->getOperand (OperandIdx) == C,
857
859
" wrong arguments: wrong operand index was provided" );
@@ -870,8 +872,7 @@ void ConstantLoader::fixSimple(int OperandIdx) {
870
872
*
871
873
* Return: new instruction
872
874
*/
873
- Instruction *ConstantLoader::loadNonSimple (Instruction *Inst)
874
- {
875
+ Instruction *ConstantLoader::loadNonSimple (Instruction *Inst) {
875
876
IGC_ASSERT (!isSimple ());
876
877
if (!isLegalSize ())
877
878
return loadBig (Inst);
@@ -1335,8 +1336,7 @@ Instruction *ConstantLoader::loadNonPackedIntConst(Instruction *InsertBefore) {
1335
1336
* ConstantLoader::loadBig : insert instruction to load a constant that might
1336
1337
* be illegally sized
1337
1338
*/
1338
- Instruction *ConstantLoader::loadBig (Instruction *InsertBefore)
1339
- {
1339
+ Instruction *ConstantLoader::loadBig (Instruction *InsertBefore) {
1340
1340
if (isLegalSize () || isa<UndefValue>(C)) {
1341
1341
// Does not need legalizing.
1342
1342
if (!isSimple ())
@@ -1388,12 +1388,11 @@ Instruction *ConstantLoader::loadBig(Instruction *InsertBefore)
1388
1388
/* **********************************************************************
1389
1389
* ConstantLoader::isLegalSize : detect if a constant is a legal size
1390
1390
*/
1391
- bool ConstantLoader::isLegalSize ()
1392
- {
1391
+ bool ConstantLoader::isLegalSize () const {
1393
1392
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
1394
1393
if (!VT)
1395
1394
return true ;
1396
- const int NumBits = DL.getTypeSizeInBits (C-> getType () );
1395
+ const int NumBits = DL.getTypeSizeInBits (VT );
1397
1396
if (!llvm::isPowerOf2_32 (NumBits))
1398
1397
return false ;
1399
1398
const int GRFSizeInBits = Subtarget.getGRFByteSize () * genx::ByteBits;
@@ -1411,7 +1410,7 @@ bool ConstantLoader::isLegalSize()
1411
1410
* This does not do a thorough check so it misses some cases of a constant
1412
1411
* that would split into simple constants.
1413
1412
*/
1414
- bool ConstantLoader::isBigSimple ()
1413
+ bool ConstantLoader::isBigSimple () const
1415
1414
{
1416
1415
IGC_ASSERT_MESSAGE (!needFixingSimple (),
1417
1416
" simple case shall be fixed first before this call" );
@@ -1432,7 +1431,7 @@ bool ConstantLoader::isBigSimple()
1432
1431
*
1433
1432
* A simple constant is one we know can be a constant operand in an instruction.
1434
1433
*/
1435
- bool ConstantLoader::isSimple ()
1434
+ bool ConstantLoader::isSimple () const
1436
1435
{
1437
1436
IGC_ASSERT_MESSAGE (!needFixingSimple (),
1438
1437
" simple case shall be fixed first before this call" );
@@ -1465,8 +1464,7 @@ bool ConstantLoader::allowI64Ops() const {
1465
1464
* ConstantLoader::isPackedIntVector : check for a packed int vector
1466
1465
* (having already done the analysis in the ConstantLoader constructor)
1467
1466
*/
1468
- bool ConstantLoader::isPackedIntVector ()
1469
- {
1467
+ bool ConstantLoader::isPackedIntVector () const {
1470
1468
// Check for a packed int vector. Either the element type must be i16, or
1471
1469
// the user (instruction using the constant) must be genx.constanti or
1472
1470
// wrregion or wrconstregion. Not allowed if the user is a logic op.
@@ -1498,7 +1496,7 @@ bool ConstantLoader::isPackedIntVector()
1498
1496
* ConstantLoader::isPackedFloatVector : check for a packed float vector
1499
1497
* (having already done the analysis in the ConstantLoader constructor)
1500
1498
*/
1501
- bool ConstantLoader::isPackedFloatVector () {
1499
+ bool ConstantLoader::isPackedFloatVector () const {
1502
1500
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
1503
1501
if (!VT)
1504
1502
return false ;
@@ -1514,8 +1512,7 @@ bool ConstantLoader::isPackedFloatVector() {
1514
1512
* A "consolidated constant" is one where a vector of byte or short is
1515
1513
* turned into the equivalent (as if by bitcast) vector of int.
1516
1514
*/
1517
- Constant *ConstantLoader::getConsolidatedConstant (Constant *C)
1518
- {
1515
+ Constant *ConstantLoader::getConsolidatedConstant (Constant *C) {
1519
1516
if (isa<UndefValue>(C))
1520
1517
return nullptr ;
1521
1518
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
@@ -1573,8 +1570,7 @@ Constant *ConstantLoader::getConsolidatedConstant(Constant *C)
1573
1570
* (integer 8 or fp 4) can be loaded as a packed vector, possibly scaled
1574
1571
* and adjusted.
1575
1572
*/
1576
- void ConstantLoader::analyze ()
1577
- {
1573
+ void ConstantLoader::analyze () {
1578
1574
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
1579
1575
if (!VT)
1580
1576
return ;
@@ -1593,8 +1589,7 @@ void ConstantLoader::analyze()
1593
1589
analyzeForPackedFloat (NumElements);
1594
1590
}
1595
1591
1596
- void ConstantLoader::analyzeForPackedInt (unsigned NumElements)
1597
- {
1592
+ void ConstantLoader::analyzeForPackedInt (unsigned NumElements) {
1598
1593
// Get element values.
1599
1594
int64_t Min = INT64_MAX;
1600
1595
int64_t Max = INT64_MIN;
0 commit comments