Skip to content

Commit c7479bf

Browse files
bcheng0127igcbot
authored andcommitted
Do LVN to flag regsiter mov
Reduce extra flag register mov instructions
1 parent e9ad10e commit c7479bf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

visa/Passes/LVN.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,22 @@ bool LVN::addValue(G4_INST *inst) {
10411041

10421042
G4_Operand *dst = inst->getDst();
10431043
if (!dst->getBase() || !dst->getBase()->isRegVar() ||
1044-
dst->getBase()->asRegVar()->getDeclare()->getRegFile() != G4_GRF ||
1044+
(dst->getBase()->asRegVar()->getDeclare()->getRegFile() != G4_GRF &&
1045+
dst->getBase()->asRegVar()->getDeclare()->getRegFile() != G4_FLAG) ||
10451046
dst->getTopDcl()->getAddressed()) {
10461047
return false;
10471048
}
10481049

1050+
// Only handle mov flag, imm
1051+
if (dst->getBase()->asRegVar()->getDeclare()->getRegFile() == G4_FLAG) {
1052+
if (inst->opcode() != G4_mov) {
1053+
return false;
1054+
}
1055+
if (!inst->getSrc(0)->isImm()) {
1056+
return false;
1057+
}
1058+
}
1059+
10491060
if (dst->getBase() && dst->getTopDcl()->isOutput()) {
10501061
return false;
10511062
}

0 commit comments

Comments
 (0)