Skip to content

Commit 25be19b

Browse files
fangliu2020igcbot
authored andcommitted
[IGC vISA] Fix the data flow analysis issue for the case that uses are scalar or indirect operands
1, If the uses are scalar or indirect 1x1/vx1 operands, we should treat the uses as if they are NoMask, and any non-NoMask instruction can't kill it. This applies to both GRF and ARF. 2, IF the uses are indirect vxh operands, we should handle address register separately but not the same as GRF in alignedWithChannelMask.
1 parent 377899c commit 25be19b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

visa/G4_IR.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,11 @@ bool G4_INST::canPropagateTo(G4_INST *useInst, Gen4_Operand_Number opndNum,
17901790
G4_Operand *use = useInst->getOperand(opndNum);
17911791
G4_Type useType = use->getType();
17921792

1793+
if (use->isIndirect()) {
1794+
// don't copy propagate for address register used in indirect access
1795+
return false;
1796+
}
1797+
17931798
// If the operand to be copied is acc register, need to check if the use
17941799
// operand can use acc register
17951800
if (src->isAccReg()) {
@@ -6020,6 +6025,12 @@ bool G4_Operand::isIndirect() const {
60206025
return false;
60216026
}
60226027

6028+
bool G4_Operand::isVxHIndirect() const {
6029+
if (isSrcRegRegion())
6030+
return asSrcRegRegion()->isVxHIndirect();
6031+
return false;
6032+
}
6033+
60236034
bool G4_Operand::crossGRF(const IR_Builder &builder) {
60246035
return getRightBound() / builder.numEltPerGRF<Type_UB>() !=
60256036
getLeftBound() / builder.numEltPerGRF<Type_UB>();

visa/G4_Operand.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class G4_Operand {
227227
G4_VarBase *getBase() { return base; }
228228
void setBase(G4_VarBase *b) { base = b; }
229229
bool isIndirect() const;
230+
bool isVxHIndirect() const;
230231

231232
const G4_Declare *getBaseRegVarRootDeclare() const;
232233
G4_Declare *getBaseRegVarRootDeclare();
@@ -598,6 +599,10 @@ class G4_SrcRegRegion final : public G4_Operand {
598599

599600
bool isIndirect() const { return acc != Direct; }
600601

602+
bool isVxHIndirect() const {
603+
return isIndirect() && getRegion()->isRegionWH() && getRegion()->width == 1;
604+
}
605+
601606
unsigned computeRightBound(uint8_t exec_size) override;
602607
G4_CmpRelation compareOperand(G4_Operand *opnd,
603608
const IR_Builder &builder) override;

visa/LocalDataflow.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,14 @@ bool LiveNode::addDefinition(G4_INST *DefInst, Gen4_Operand_Number DefOpNum,
261261

262262
bool LiveNode::dependsOnChannelMask(bool IsInSimdFlow, G4_INST *Inst,
263263
Gen4_Operand_Number OpNum) {
264-
if (!IsInSimdFlow || Inst->isWriteEnableInst())
264+
// Treat scalar and indirect 1x1/Vx1 uses as noMask. Any non-noMask
265+
// inst can't kill it.
266+
auto opnd = Inst->getOperand(OpNum);
267+
bool isScalarSrc = opnd->isScalarSrc();
268+
bool isIndirect1x1Vx1 = opnd->isIndirect() && !opnd->isVxHIndirect();
269+
270+
if (!IsInSimdFlow || Inst->isWriteEnableInst() || isScalarSrc ||
271+
isIndirect1x1Vx1)
265272
return false;
266273

267274
// Otherwise.
@@ -304,6 +311,13 @@ bool LiveNode::alignedWithChannelMask(G4_INST *DefInst,
304311
return DefOffset == UseOffset;
305312
}
306313

314+
// UseOpnd is indirect VxH
315+
if (UseOpnd->isVxHIndirect()) {
316+
int DefOffset = int(DefLB - DefMaskOffset * TypeSize(ADDR_REG_TYPE));
317+
int UseOffset = int(UseLB - UseMaskOffset * TypeSize(ADDR_REG_TYPE));
318+
return DefOffset == UseOffset;
319+
}
320+
307321
// Do not analyze instructions that may exceed two GRF boundary
308322
if (DefInst->mayExceedTwoGRF() || UseInst->mayExceedTwoGRF())
309323
return true;

0 commit comments

Comments
 (0)