Skip to content

Commit f85f5e1

Browse files
fangliu2020igcbot
authored andcommitted
Do not generate mad if both src1 and src2 are :b type
1 parent e65340b commit f85f5e1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

visa/HWConformity.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,7 +4038,7 @@ bool HWConformity::generateAlign1Mad(G4_BB* bb, INST_LIST_ITER iter)
40384038

40394039
// check src
40404040
bool canBeImm = true;
4041-
for (int k = 0; k < inst->getNumSrc(); k++)
4041+
for (int k = inst->getNumSrc() - 1; k >= 0; k--)
40424042
{
40434043
G4_Operand* src = inst->getSrc(k);
40444044
if (!isGoodAlign1TernarySrc(inst, k, canBeImm))
@@ -4062,8 +4062,11 @@ bool HWConformity::generateAlign1Mad(G4_BB* bb, INST_LIST_ITER iter)
40624062
// =>
40634063
// mov (1) TV74(0,0)<1>:w V106(0,0)<0;1,0>:b {Q1, Align1, NoMask}
40644064
// mad (16) V211(0,0)<1>:d V81(0,0)<1;0>:d V210(0,0)<1;0>:d TV74(0,0)<0;0>:w {H1, Align1}
4065+
// Do not allow mad if both src1 and src2 are :b as it will generate mov+mov+mad. There is no benefit for
4066+
// instruction count as mov+mov+mas equals to mov+mul+add. In some spilled cases the performace may be
4067+
// even worse as more spill codes inserted.
40654068
bool isSrc2 = (k == 0);
4066-
if (builder.noSrc2Regioning() && isSrc2 && IS_BTYPE(src->getType()))
4069+
if (builder.noSrc2Regioning() && isSrc2 && IS_BTYPE(src->getType()) && !IS_BTYPE(inst->getSrc(1)->getType()))
40674070
{
40684071
bool hasModMinus = false;
40694072
if (src->isSrcRegRegion())

0 commit comments

Comments
 (0)