summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2020-09-22 22:48:06 -0400
committerGravatar Lioncash2020-09-22 22:48:09 -0400
commitfcd0145eb5cbba9a603455c3ce35cfa44d814d98 (patch)
treed3b18bb1765c9b8bdafb96c42e84cfe9b4a7dd10
parentMerge pull request #4698 from lioncash/optional-null (diff)
downloadyuzu-fcd0145eb5cbba9a603455c3ce35cfa44d814d98.tar.gz
yuzu-fcd0145eb5cbba9a603455c3ce35cfa44d814d98.tar.xz
yuzu-fcd0145eb5cbba9a603455c3ce35cfa44d814d98.zip
control_flow: Make use of std::move in InsertBranch()
Avoids unnecessary atomic increments and decrements.
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/control_flow.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/video_core/shader/control_flow.cpp b/src/video_core/shader/control_flow.cpp
index 336397cdb..5963cf214 100644
--- a/src/video_core/shader/control_flow.cpp
+++ b/src/video_core/shader/control_flow.cpp
@@ -580,8 +580,8 @@ bool TryQuery(CFGRebuildState& state) {
580} 580}
581 581
582void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { 582void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) {
583 const auto get_expr = ([&](const Condition& cond) -> Expr { 583 const auto get_expr = [](const Condition& cond) -> Expr {
584 Expr result{}; 584 Expr result;
585 if (cond.cc != ConditionCode::T) { 585 if (cond.cc != ConditionCode::T) {
586 result = MakeExpr<ExprCondCode>(cond.cc); 586 result = MakeExpr<ExprCondCode>(cond.cc);
587 } 587 }
@@ -594,10 +594,10 @@ void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) {
594 } 594 }
595 Expr extra = MakeExpr<ExprPredicate>(pred); 595 Expr extra = MakeExpr<ExprPredicate>(pred);
596 if (negate) { 596 if (negate) {
597 extra = MakeExpr<ExprNot>(extra); 597 extra = MakeExpr<ExprNot>(std::move(extra));
598 } 598 }
599 if (result) { 599 if (result) {
600 return MakeExpr<ExprAnd>(extra, result); 600 return MakeExpr<ExprAnd>(std::move(extra), std::move(result));
601 } 601 }
602 return extra; 602 return extra;
603 } 603 }
@@ -605,9 +605,10 @@ void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) {
605 return result; 605 return result;
606 } 606 }
607 return MakeExpr<ExprBoolean>(true); 607 return MakeExpr<ExprBoolean>(true);
608 }); 608 };
609
609 if (std::holds_alternative<SingleBranch>(*branch_info)) { 610 if (std::holds_alternative<SingleBranch>(*branch_info)) {
610 const auto branch = std::get_if<SingleBranch>(branch_info.get()); 611 const auto* branch = std::get_if<SingleBranch>(branch_info.get());
611 if (branch->address < 0) { 612 if (branch->address < 0) {
612 if (branch->kill) { 613 if (branch->kill) {
613 mm.InsertReturn(get_expr(branch->condition), true); 614 mm.InsertReturn(get_expr(branch->condition), true);
@@ -619,7 +620,7 @@ void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) {
619 mm.InsertGoto(get_expr(branch->condition), branch->address); 620 mm.InsertGoto(get_expr(branch->condition), branch->address);
620 return; 621 return;
621 } 622 }
622 const auto multi_branch = std::get_if<MultiBranch>(branch_info.get()); 623 const auto* multi_branch = std::get_if<MultiBranch>(branch_info.get());
623 for (const auto& branch_case : multi_branch->branches) { 624 for (const auto& branch_case : multi_branch->branches) {
624 mm.InsertGoto(MakeExpr<ExprGprEqual>(multi_branch->gpr, branch_case.cmp_value), 625 mm.InsertGoto(MakeExpr<ExprGprEqual>(multi_branch->gpr, branch_case.cmp_value),
625 branch_case.address); 626 branch_case.address);