Skip to content

Commit 756595a

Browse files
jgu222igcbot
authored andcommitted
Add missing implicit acc dst for madw
madw has implicit def to acc. Missing this implicit dst causes copyprop incorrectly propagates acc src over madw.
1 parent 5d02323 commit 756595a

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

visa/G4_IR.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,8 +1573,7 @@ bool G4_INST::hasACCOpnd() const
15731573
(dst && dst->isAccReg()) ||
15741574
(srcs[0] && srcs[0]->isAccReg()) ||
15751575
(srcs[1] && srcs[1]->isAccReg()) ||
1576-
(srcs[2] && srcs[2]->isAccReg()) ||
1577-
op == G4_madw);
1576+
(srcs[2] && srcs[2]->isAccReg()));
15781577
}
15791578

15801579
G4_Type G4_INST::getOpExecType(int& extypesize)

visa/HWConformity.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9455,12 +9455,6 @@ INST_LIST_ITER HWConformity::fixMadwInst(INST_LIST_ITER it, G4_BB* bb)
94559455
madwInst->setSrc(insertMovBefore(it, 0, src0->getType(), bb), 0);
94569456
}
94579457
}
9458-
9459-
// add implicit acc dst to the madw instruction as acc will be used as dst of the expanded mul after local scheduling.
9460-
// it is a must to fix the WAR/WAW issue of acc in local scheduling.
9461-
G4_DstRegRegion* accDstOpnd = builder.createDst(builder.phyregpool.getAcc0Reg(), 0, 0, 1, madwInst->getDst()->getType());
9462-
madwInst->setImplAccDst(accDstOpnd);
9463-
94649458
retIter = std::next(it);
94659459
}
94669460
else
@@ -9476,6 +9470,9 @@ INST_LIST_ITER HWConformity::fixMadwInst(INST_LIST_ITER it, G4_BB* bb)
94769470
// mach (16) dst_hi32<1>:d src0<1;1,0>:d src1<1;1,0>:d // High 32 bits
94779471
// mov (16) dst_lo32<1>:d acc0.0<1;1,0>:d // Low 32 bits
94789472

9473+
// unset AccWrCtrl
9474+
madwInst->setOptionOff(InstOpt_AccWrCtrl);
9475+
94799476
uint32_t origOptions = madwInst->getOption();
94809477
G4_Predicate* origPredicate = madwInst->getPredicate();
94819478
G4_Type tmpType = (IS_UNSIGNED_INT(src0->getType()) && IS_UNSIGNED_INT(src1->getType()) && IS_UNSIGNED_INT(src2->getType())) ? Type_UD : Type_D;

visa/Optimizer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16849,6 +16849,9 @@ void Optimizer::expandMadwPostSchedule()
1684916849
continue;
1685016850
}
1685116851

16852+
// Unset a AccWrCtrl first.
16853+
inst->setOptionOff(InstOpt_AccWrCtrl);
16854+
1685216855
G4_Operand* src0 = inst->getSrc(0);
1685316856
G4_Operand* src1 = inst->getSrc(1);
1685416857
G4_Operand* src2 = inst->getSrc(2);

visa/VisaToG4/TranslateALU.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int IR_Builder::translateVISAArithmeticInst(
109109
}
110110

111111
// do not check type of sources, float and integer are supported
112-
createInst(
112+
auto inst = createInst(
113113
predOpnd,
114114
GetGenOpcodeFromVISAOpcode(opcode),
115115
condMod,
@@ -121,6 +121,19 @@ int IR_Builder::translateVISAArithmeticInst(
121121
src2Opnd,
122122
instOpt,
123123
true);
124+
125+
if (opcode == ISA_MADW)
126+
{
127+
G4_DstRegRegion* accDstOpnd = createDst(
128+
phyregpool.getAcc0Reg(),
129+
0,
130+
0,
131+
1,
132+
dstOpnd->getType());
133+
134+
inst->setImplAccDst(accDstOpnd);
135+
inst->setOptionOn(InstOpt_AccWrCtrl); // to be consistent with impl Acc.
136+
}
124137
}
125138
else
126139
{

0 commit comments

Comments
 (0)