Avoid one redundant call to IsReachable.

PiperOrigin-RevId: 315912341
Change-Id: I1b576cc9afecf1c7aa7f1c1ecef23a0017b7c92e
This commit is contained in:
Jeffrey A. Dean 2020-06-11 09:18:41 -07:00 committed by TensorFlower Gardener
parent 45eecdb007
commit b09d05b6b1

View File

@ -350,12 +350,13 @@ void MultiOutputFusion::UpdateReachability(
if (skip != nullptr && skip(instr)) {
continue;
}
if (reachability_->IsReachable(instr2, instr) &&
reachability_->IsReachable(instr1, instr)) {
bool instr2_instr = reachability_->IsReachable(instr2, instr);
bool instr1_instr = reachability_->IsReachable(instr1, instr);
if (instr2_instr && instr1_instr) {
// If a candidate was already reachable by both, no update needed.
continue;
}
if (reachability_->IsReachable(instr2, instr)) {
if (instr2_instr) {
reachability_->FastSetReachabilityToUnion({instr, instr1}, instr);
}
if (reachability_->IsReachable(instr1, instr)) {