Skip to content

Commit 9896d24

Browse files
aparshin-inteligcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: ce85e34
minor cosmetic changes to VC ConstantLoader ---------------------------
1 parent e6b0d10 commit 9896d24

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXConstants.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ bool genx::loadNonSimpleConstants(
172172
continue;
173173
ConstantLoader CL(C, Subtarget, DL, Inst, AddedInstructions);
174174
if (CL.needFixingSimple()) {
175-
Modified = true;
176175
CL.fixSimple(i);
177176
continue;
178177
}
@@ -774,7 +773,7 @@ bool genx::loadPhiConstants(Function &F, DominatorTree *DT,
774773
Value *Load = nullptr;
775774
Instruction *InsertBefore = InsertBB->getTerminator();
776775
if (!CL.isSimple())
777-
Load = CL.loadBig(InsertBefore);
776+
Load = CL.loadNonSimple(InsertBefore);
778777
else
779778
Load = CL.load(InsertBefore);
780779
Modified = true;
@@ -853,7 +852,6 @@ bool genx::isReplicatedConstantVector(
853852
}
854853

855854
void ConstantLoader::fixSimple(int OperandIdx) {
856-
IGC_ASSERT_MESSAGE(User, "user must be provided");
857855
IGC_ASSERT_MESSAGE(NewC, "no need to fix simple case");
858856
IGC_ASSERT_MESSAGE(User->getOperand(OperandIdx) == C,
859857
"wrong arguments: wrong operand index was provided");
@@ -872,7 +870,8 @@ void ConstantLoader::fixSimple(int OperandIdx) {
872870
*
873871
* Return: new instruction
874872
*/
875-
Instruction *ConstantLoader::loadNonSimple(Instruction *Inst) {
873+
Instruction *ConstantLoader::loadNonSimple(Instruction *Inst)
874+
{
876875
IGC_ASSERT(!isSimple());
877876
if (!isLegalSize())
878877
return loadBig(Inst);
@@ -1336,7 +1335,8 @@ Instruction *ConstantLoader::loadNonPackedIntConst(Instruction *InsertBefore) {
13361335
* ConstantLoader::loadBig : insert instruction to load a constant that might
13371336
* be illegally sized
13381337
*/
1339-
Instruction *ConstantLoader::loadBig(Instruction *InsertBefore) {
1338+
Instruction *ConstantLoader::loadBig(Instruction *InsertBefore)
1339+
{
13401340
if (isLegalSize() || isa<UndefValue>(C)) {
13411341
// Does not need legalizing.
13421342
if (!isSimple())
@@ -1388,11 +1388,12 @@ Instruction *ConstantLoader::loadBig(Instruction *InsertBefore) {
13881388
/***********************************************************************
13891389
* ConstantLoader::isLegalSize : detect if a constant is a legal size
13901390
*/
1391-
bool ConstantLoader::isLegalSize() const {
1391+
bool ConstantLoader::isLegalSize()
1392+
{
13921393
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
13931394
if (!VT)
13941395
return true;
1395-
const int NumBits = DL.getTypeSizeInBits(VT);
1396+
const int NumBits = DL.getTypeSizeInBits(C->getType());
13961397
if (!llvm::isPowerOf2_32(NumBits))
13971398
return false;
13981399
const int GRFSizeInBits = Subtarget.getGRFByteSize() * genx::ByteBits;
@@ -1410,7 +1411,7 @@ bool ConstantLoader::isLegalSize() const {
14101411
* This does not do a thorough check so it misses some cases of a constant
14111412
* that would split into simple constants.
14121413
*/
1413-
bool ConstantLoader::isBigSimple() const
1414+
bool ConstantLoader::isBigSimple()
14141415
{
14151416
IGC_ASSERT_MESSAGE(!needFixingSimple(),
14161417
"simple case shall be fixed first before this call");
@@ -1431,7 +1432,7 @@ bool ConstantLoader::isBigSimple() const
14311432
*
14321433
* A simple constant is one we know can be a constant operand in an instruction.
14331434
*/
1434-
bool ConstantLoader::isSimple() const
1435+
bool ConstantLoader::isSimple()
14351436
{
14361437
IGC_ASSERT_MESSAGE(!needFixingSimple(),
14371438
"simple case shall be fixed first before this call");
@@ -1464,7 +1465,8 @@ bool ConstantLoader::allowI64Ops() const {
14641465
* ConstantLoader::isPackedIntVector : check for a packed int vector
14651466
* (having already done the analysis in the ConstantLoader constructor)
14661467
*/
1467-
bool ConstantLoader::isPackedIntVector() const {
1468+
bool ConstantLoader::isPackedIntVector()
1469+
{
14681470
// Check for a packed int vector. Either the element type must be i16, or
14691471
// the user (instruction using the constant) must be genx.constanti or
14701472
// wrregion or wrconstregion. Not allowed if the user is a logic op.
@@ -1496,7 +1498,7 @@ bool ConstantLoader::isPackedIntVector() const {
14961498
* ConstantLoader::isPackedFloatVector : check for a packed float vector
14971499
* (having already done the analysis in the ConstantLoader constructor)
14981500
*/
1499-
bool ConstantLoader::isPackedFloatVector() const {
1501+
bool ConstantLoader::isPackedFloatVector() {
15001502
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
15011503
if (!VT)
15021504
return false;
@@ -1512,7 +1514,8 @@ bool ConstantLoader::isPackedFloatVector() const {
15121514
* A "consolidated constant" is one where a vector of byte or short is
15131515
* turned into the equivalent (as if by bitcast) vector of int.
15141516
*/
1515-
Constant *ConstantLoader::getConsolidatedConstant(Constant *C) {
1517+
Constant *ConstantLoader::getConsolidatedConstant(Constant *C)
1518+
{
15161519
if (isa<UndefValue>(C))
15171520
return nullptr;
15181521
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
@@ -1570,7 +1573,8 @@ Constant *ConstantLoader::getConsolidatedConstant(Constant *C) {
15701573
* (integer 8 or fp 4) can be loaded as a packed vector, possibly scaled
15711574
* and adjusted.
15721575
*/
1573-
void ConstantLoader::analyze() {
1576+
void ConstantLoader::analyze()
1577+
{
15741578
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
15751579
if (!VT)
15761580
return;
@@ -1589,7 +1593,8 @@ void ConstantLoader::analyze() {
15891593
analyzeForPackedFloat(NumElements);
15901594
}
15911595

1592-
void ConstantLoader::analyzeForPackedInt(unsigned NumElements) {
1596+
void ConstantLoader::analyzeForPackedInt(unsigned NumElements)
1597+
{
15931598
// Get element values.
15941599
int64_t Min = INT64_MAX;
15951600
int64_t Max = INT64_MIN;

IGC/VectorCompiler/lib/GenXCodeGen/GenXConstants.h

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ SPDX-License-Identifier: MIT
66
77
============================= end_copyright_notice ===========================*/
88

9-
#ifndef LIB_GENXCODEGEN_GENXCONSTANTS_H
10-
#define LIB_GENXCODEGEN_GENXCONSTANTS_H
9+
#ifndef GENX_CONSTANTS_H
10+
#define GENX_CONSTANTS_H
1111

1212
#include "GenXSubtarget.h"
1313
#include "llvm/ADT/SmallVector.h"
@@ -20,10 +20,6 @@ namespace genx {
2020

2121
// ConstantLoader : class to insert instruction(s) to load a constant
2222
class ConstantLoader {
23-
friend bool loadNonSimpleConstants(
24-
Instruction *Inst, const GenXSubtarget &Subtarget, const DataLayout &DL,
25-
SmallVectorImpl<Instruction *> *AddedInstructions);
26-
2723
Constant *C;
2824
Instruction *User;
2925

@@ -62,34 +58,27 @@ class ConstantLoader {
6258
AddedInstructions(AddedInstructions) {
6359
analyze();
6460
}
65-
6661
Instruction *load(Instruction *InsertBefore);
6762
Instruction *loadBig(Instruction *InsertBefore);
68-
69-
bool isBigSimple() const;
70-
bool isSimple() const;
71-
bool isLegalSize() const;
63+
Instruction *loadNonSimple(Instruction *InsertBefore);
64+
Instruction *loadNonPackedIntConst(Instruction *InsertBefore);
65+
bool needFixingSimple() const { return NewC; }
66+
void fixSimple(int OperandIdx);
67+
bool isBigSimple();
68+
bool isSimple();
69+
bool isLegalSize();
7270

7371
private:
7472
bool allowI64Ops() const;
75-
73+
bool isPackedIntVector();
74+
bool isPackedFloatVector();
7675
void analyze();
77-
void analyzeForPackedInt(unsigned NumElements);
78-
void analyzeForPackedFloat(unsigned NumElements);
79-
80-
bool isPackedIntVector() const;
81-
bool isPackedFloatVector() const;
82-
8376
Constant *getConsolidatedConstant(Constant *C);
8477
unsigned getRegionBits(unsigned NeededBits, unsigned OptionalBits,
8578
unsigned VecWidth);
86-
87-
bool needFixingSimple() const { return NewC; }
88-
void fixSimple(int OperandIdx);
89-
90-
Instruction *loadNonSimple(Instruction *InsertBefore);
91-
Instruction *loadSplatConstant(Instruction *InsertPt);
92-
Instruction *loadNonPackedIntConst(Instruction *InsertPt);
79+
void analyzeForPackedInt(unsigned NumElements);
80+
void analyzeForPackedFloat(unsigned NumElements);
81+
Instruction *loadSplatConstant(Instruction *InsertPos);
9382
};
9483

9584
// Some instructions force their operands to be constants.
@@ -145,4 +134,4 @@ bool isReplicatedConstantVector(const ConstantVector *Orig,
145134
} // namespace genx
146135
} // namespace llvm
147136

148-
#endif // LIB_GENXCODEGEN_GENXCONSTANTS_H
137+
#endif // GENX_CONSTANTS_H

0 commit comments

Comments
 (0)