@@ -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);
@@ -1153,8 +1154,7 @@ Instruction *ConstantLoader::loadNonSimple(Instruction *Inst)
1153
1154
* maximizing how many of NeededBits are set
1154
1155
*/
1155
1156
unsigned ConstantLoader::getRegionBits (unsigned NeededBits,
1156
- unsigned OptionalBits, unsigned VecWidth)
1157
- {
1157
+ unsigned OptionalBits, unsigned VecWidth) {
1158
1158
if (!NeededBits)
1159
1159
return 0 ;
1160
1160
// Get the first and last element numbers in NeededBits.
@@ -1257,8 +1257,7 @@ Instruction *ConstantLoader::loadSplatConstant(Instruction *InsertPos) {
1257
1257
*
1258
1258
* Return: new instruction
1259
1259
*/
1260
- Instruction *ConstantLoader::load (Instruction *InsertBefore)
1261
- {
1260
+ Instruction *ConstantLoader::load (Instruction *InsertBefore) {
1262
1261
IGC_ASSERT (isSimple ());
1263
1262
// Do not splat load on byte data as HW does not support byte imm source.
1264
1263
if (!C->getType ()->getScalarType ()->isIntegerTy (8 ))
@@ -1335,8 +1334,7 @@ Instruction *ConstantLoader::loadNonPackedIntConst(Instruction *InsertBefore) {
1335
1334
* ConstantLoader::loadBig : insert instruction to load a constant that might
1336
1335
* be illegally sized
1337
1336
*/
1338
- Instruction *ConstantLoader::loadBig (Instruction *InsertBefore)
1339
- {
1337
+ Instruction *ConstantLoader::loadBig (Instruction *InsertBefore) {
1340
1338
if (isLegalSize () || isa<UndefValue>(C)) {
1341
1339
// Does not need legalizing.
1342
1340
if (!isSimple ())
@@ -1388,12 +1386,11 @@ Instruction *ConstantLoader::loadBig(Instruction *InsertBefore)
1388
1386
/* **********************************************************************
1389
1387
* ConstantLoader::isLegalSize : detect if a constant is a legal size
1390
1388
*/
1391
- bool ConstantLoader::isLegalSize ()
1392
- {
1389
+ bool ConstantLoader::isLegalSize () const {
1393
1390
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
1394
1391
if (!VT)
1395
1392
return true ;
1396
- const int NumBits = DL.getTypeSizeInBits (C-> getType () );
1393
+ const int NumBits = DL.getTypeSizeInBits (VT );
1397
1394
if (!llvm::isPowerOf2_32 (NumBits))
1398
1395
return false ;
1399
1396
const int GRFSizeInBits = Subtarget.getGRFByteSize () * genx::ByteBits;
@@ -1411,8 +1408,7 @@ bool ConstantLoader::isLegalSize()
1411
1408
* This does not do a thorough check so it misses some cases of a constant
1412
1409
* that would split into simple constants.
1413
1410
*/
1414
- bool ConstantLoader::isBigSimple ()
1415
- {
1411
+ bool ConstantLoader::isBigSimple () const {
1416
1412
IGC_ASSERT_MESSAGE (!needFixingSimple (),
1417
1413
" simple case shall be fixed first before this call" );
1418
1414
if (isa<UndefValue>(C))
@@ -1432,8 +1428,7 @@ bool ConstantLoader::isBigSimple()
1432
1428
*
1433
1429
* A simple constant is one we know can be a constant operand in an instruction.
1434
1430
*/
1435
- bool ConstantLoader::isSimple ()
1436
- {
1431
+ bool ConstantLoader::isSimple () const {
1437
1432
IGC_ASSERT_MESSAGE (!needFixingSimple (),
1438
1433
" simple case shall be fixed first before this call" );
1439
1434
if (isa<UndefValue>(C))
@@ -1465,8 +1460,7 @@ bool ConstantLoader::allowI64Ops() const {
1465
1460
* ConstantLoader::isPackedIntVector : check for a packed int vector
1466
1461
* (having already done the analysis in the ConstantLoader constructor)
1467
1462
*/
1468
- bool ConstantLoader::isPackedIntVector ()
1469
- {
1463
+ bool ConstantLoader::isPackedIntVector () const {
1470
1464
// Check for a packed int vector. Either the element type must be i16, or
1471
1465
// the user (instruction using the constant) must be genx.constanti or
1472
1466
// wrregion or wrconstregion. Not allowed if the user is a logic op.
@@ -1498,7 +1492,7 @@ bool ConstantLoader::isPackedIntVector()
1498
1492
* ConstantLoader::isPackedFloatVector : check for a packed float vector
1499
1493
* (having already done the analysis in the ConstantLoader constructor)
1500
1494
*/
1501
- bool ConstantLoader::isPackedFloatVector () {
1495
+ bool ConstantLoader::isPackedFloatVector () const {
1502
1496
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
1503
1497
if (!VT)
1504
1498
return false ;
@@ -1514,8 +1508,7 @@ bool ConstantLoader::isPackedFloatVector() {
1514
1508
* A "consolidated constant" is one where a vector of byte or short is
1515
1509
* turned into the equivalent (as if by bitcast) vector of int.
1516
1510
*/
1517
- Constant *ConstantLoader::getConsolidatedConstant (Constant *C)
1518
- {
1511
+ Constant *ConstantLoader::getConsolidatedConstant (Constant *C) {
1519
1512
if (isa<UndefValue>(C))
1520
1513
return nullptr ;
1521
1514
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
@@ -1573,8 +1566,7 @@ Constant *ConstantLoader::getConsolidatedConstant(Constant *C)
1573
1566
* (integer 8 or fp 4) can be loaded as a packed vector, possibly scaled
1574
1567
* and adjusted.
1575
1568
*/
1576
- void ConstantLoader::analyze ()
1577
- {
1569
+ void ConstantLoader::analyze () {
1578
1570
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
1579
1571
if (!VT)
1580
1572
return ;
@@ -1593,8 +1585,7 @@ void ConstantLoader::analyze()
1593
1585
analyzeForPackedFloat (NumElements);
1594
1586
}
1595
1587
1596
- void ConstantLoader::analyzeForPackedInt (unsigned NumElements)
1597
- {
1588
+ void ConstantLoader::analyzeForPackedInt (unsigned NumElements) {
1598
1589
// Get element values.
1599
1590
int64_t Min = INT64_MAX;
1600
1591
int64_t Max = INT64_MIN;
0 commit comments