diff --git a/src/passes/ConstraintAnalysis.cpp b/src/passes/ConstraintAnalysis.cpp index d16a326dc29..0c7e940577c 100644 --- a/src/passes/ConstraintAnalysis.cpp +++ b/src/passes/ConstraintAnalysis.cpp @@ -165,14 +165,19 @@ struct ConstraintAnalysis // Find the constraints sent to this specific successor, if there is a // branch, and use them. - auto sentConstraints = constraints; if (auto branch = getBranchConstraints(block, out)) { + auto sentConstraints = constraints; sentConstraints.approximateAnd(branch->local, branch->constraint); - } - - // If anything changed at the start of the target block, flow onwards. - if (outStartConstraints.approximateOr(sentConstraints)) { - work.push(out); + // If anything changed at the start of the target block, flow onwards. + if (outStartConstraints.approximateOr(sentConstraints)) { + work.push(out); + } + } else { + // There are no specific branch constraints, so send the unmodified + // |constraints|, avoiding a copy. + if (outStartConstraints.approximateOr(constraints)) { + work.push(out); + } } } }