Skip to content

Commit 88b3b8a

Browse files
weiyu-chensys_zuul
authored andcommitted
Check if the resulting instruction supports source modifier for copy propagation and def-hoisting.
Change-Id: Ifa15aa82bae40d6e3bcd61abe1b128f887613272
1 parent 575e284 commit 88b3b8a

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

visa/Gen4_IR.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ bool G4_INST::canPropagateTo(
22662266
if (src->isImm())
22672267
{
22682268
if (isFloatPseudoMAD(useInst) || useInst->opcode() == G4_math ||
2269-
use->asSrcRegRegion()->getModifier() != Mod_src_undef)
2269+
use->asSrcRegRegion()->hasModifier())
22702270
{
22712271
return false;
22722272
}
@@ -2331,6 +2331,11 @@ bool G4_INST::canPropagateTo(
23312331
return false;
23322332
}
23332333

2334+
if (hasModifier && !useInst->canSupportSrcModifier())
2335+
{
2336+
return false;
2337+
}
2338+
23342339
// Check 'dst' of MOV and 'use' are the same variable. Otherwise, it's not
23352340
// legal to be propagated.
23362341
G4_CmpRelation rel = dst->compareOperand(use);
@@ -2347,6 +2352,7 @@ bool G4_INST::canPropagateTo(
23472352
return false;
23482353
}
23492354

2355+
23502356
// Don't propagate unsupported propType.
23512357
if (!useInst->isLegalType(propType, opndNum))
23522358
{
@@ -2482,7 +2488,7 @@ bool G4_INST::canPropagateTo(
24822488
return false;
24832489
}
24842490

2485-
if (src->isImm() && use->asSrcRegRegion()->getModifier() != Mod_src_undef)
2491+
if (src->isImm() && use->asSrcRegRegion()->hasModifier())
24862492
{
24872493
//FIXME: do we need to worry about signal bit in NaN being dropped?
24882494
if (IS_TYPE_INT(srcType))
@@ -2826,6 +2832,21 @@ bool G4_INST::canHoistTo(const G4_INST *defInst, bool simdBB) const
28262832
}
28272833
}
28282834

2835+
bool hasSrcModifier = false;
2836+
for (int i = 0, numSrc = defInst->getNumSrc(); i < numSrc; ++i)
2837+
{
2838+
if (defInst->getSrc(i)->isSrcRegRegion() && defInst->getSrc(i)->asSrcRegRegion()->hasModifier())
2839+
{
2840+
hasSrcModifier = true;
2841+
break;
2842+
}
2843+
}
2844+
if (hasSrcModifier && !this->canSupportSrcModifier())
2845+
{
2846+
return false;
2847+
}
2848+
2849+
28292850

28302851
return true;
28312852
}
@@ -7128,6 +7149,15 @@ bool G4_INST::canSupportCondMod() const
71287149

71297150
bool G4_INST::canSupportSrcModifier() const
71307151
{
7152+
7153+
7154+
if (opcode() == G4_pseudo_mad)
7155+
{
7156+
return true;
7157+
}
7158+
7159+
// note that IGA will return false for any opcode it does not recognize
7160+
// If your psuedo opcode needs to support source modifier you must add explicit check before this
71317161
const iga::Model* igaModel = builder.getIGAModel();
71327162

71337163
assert(igaModel != nullptr);

0 commit comments

Comments
 (0)