Skip to content

Commit 342359b

Browse files
azabaznosys_zuul
authored andcommitted
Change to make VectorDecomposer use subtarget info
Change-Id: I82476d4e51c1c52e51c35aa44489fdb821dfac64
1 parent 2a299dc commit 342359b

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPostLegalization.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ namespace {
7575
// GenXPostLegalization : post-legalization pass
7676
class GenXPostLegalization : public FunctionPass {
7777
DominatorTree *DT = nullptr;
78-
VectorDecomposer VD;
7978
const DataLayout *DL = nullptr;
8079
const GenXSubtarget *ST = nullptr;
8180
public:
@@ -122,6 +121,9 @@ bool GenXPostLegalization::runOnFunction(Function &F)
122121
bool Modified = false;
123122
Modified |= breakConstantExprs(&F);
124123

124+
// Create vector decomposer helper
125+
auto VD = std::make_unique<VectorDecomposer>(ST, DT);
126+
125127
for (Function::iterator fi = F.begin(), fe = F.end(); fi != fe; ++fi) {
126128
BasicBlock *BB = &*fi;
127129
for (BasicBlock::iterator bi = BB->begin(), be = BB->end(); bi != be; ++bi) {
@@ -142,15 +144,15 @@ bool GenXPostLegalization::runOnFunction(Function &F)
142144
if (!ST->disableVectorDecomposition()) {
143145
if (GenXIntrinsic::isWrRegion(Inst)) {
144146
if (isa<Constant>(Inst->getOperand(0)))
145-
VD.addStartWrRegion(Inst);
147+
VD->addStartWrRegion(Inst);
146148
else if (isa<PHINode>(Inst->getOperand(0)))
147-
VD.addStartWrRegion(Inst);
149+
VD->addStartWrRegion(Inst);
148150
}
149151
}
150152
}
151153
}
152154
// Run the vector decomposer for this function.
153-
Modified |= VD.run(DT);
155+
Modified |= VD->run();
154156
// Cleanup region reads and writes.
155157
Modified |= simplifyRegionInsts(&F, DL);
156158
// Cleanup redundant global loads.

IGC/VectorCompiler/lib/GenXCodeGen/GenXVectorDecomposer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ int DiagnosticVectorDecomposition::KindID = 0;
120120
*
121121
* Return: true if code modified
122122
*/
123-
bool VectorDecomposer::run(DominatorTree *ArgDT)
124-
{
125-
DT = ArgDT;
123+
bool VectorDecomposer::run() {
126124
DL = &DT->
127125
getRoot()
128126
->getModule()
@@ -190,7 +188,10 @@ bool VectorDecomposer::determineDecomposition(Instruction *Inst)
190188
NotDecomposingReportInst = Inst;
191189
Web.clear();
192190
Decomposition.clear();
193-
unsigned NumGrfs = alignTo<256>(DL->getTypeSizeInBits(Inst->getType())) / 256;
191+
unsigned GRFWidth = ST ? ST->getGRFWidth() : defaultGRFWidth;
192+
unsigned NumGrfs = alignTo(DL->getTypeSizeInBits(Inst->getType()),
193+
GRFWidth * genx::ByteBits) /
194+
(GRFWidth * genx::ByteBits);
194195
if (NumGrfs == 1)
195196
return false; // Ignore single GRF vector.
196197
LLVM_DEBUG(dbgs() << "VectorDecomposer::determineDecomposition(" << Inst->getName() << ")\n");

IGC/VectorCompiler/lib/GenXCodeGen/GenXVectorDecomposer.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Region;
6868

6969
// VectorDecomposer : decomposes vectors in a function
7070
class VectorDecomposer {
71+
const GenXSubtarget *ST;
7172
DominatorTree *DT;
7273
const DataLayout *DL = nullptr;
7374
SmallVector<Instruction *, 16> StartWrRegions;
@@ -81,6 +82,9 @@ class VectorDecomposer {
8182
std::map<PHINode *, SmallVector<Value *, 8>> PhiParts;
8283
SmallVector<Instruction *, 8> NewInsts;
8384
public:
85+
VectorDecomposer(const GenXSubtarget *Subtarget, DominatorTree *DTree)
86+
: ST(Subtarget), DT(DTree) {}
87+
8488
// clear : clear anything stored
8589
void clear() {
8690
clearOne();
@@ -91,7 +95,8 @@ class VectorDecomposer {
9195
// addStartWrRegion : add a wrregion with undef input to the list
9296
void addStartWrRegion(Instruction *Inst) { StartWrRegions.push_back(Inst); }
9397
// run : run the vector decomposer on the stored StartWrRegions
94-
bool run(DominatorTree *DT);
98+
bool run();
99+
95100
private:
96101
// clearOne : clear from processing one web
97102
void clearOne() {

0 commit comments

Comments
 (0)