video_core/control_flow: Eliminate pessimizing moves

These can inhibit the ability of a compiler to perform RVO.
master
Lioncash 2019-10-05 08:52:20 +07:00
parent d82b181d44
commit 25702b6256
1 changed files with 8 additions and 5 deletions

@ -479,7 +479,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
auto result_out = std::make_unique<ShaderCharacteristics>(); auto result_out = std::make_unique<ShaderCharacteristics>();
if (settings.depth == CompileDepth::BruteForce) { if (settings.depth == CompileDepth::BruteForce) {
result_out->settings.depth = CompileDepth::BruteForce; result_out->settings.depth = CompileDepth::BruteForce;
return std::move(result_out); return result_out;
} }
CFGRebuildState state{program_code, program_size, start_address}; CFGRebuildState state{program_code, program_size, start_address};
@ -490,7 +490,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
while (!state.inspect_queries.empty()) { while (!state.inspect_queries.empty()) {
if (!TryInspectAddress(state)) { if (!TryInspectAddress(state)) {
result_out->settings.depth = CompileDepth::BruteForce; result_out->settings.depth = CompileDepth::BruteForce;
return std::move(result_out); return result_out;
} }
} }
@ -535,9 +535,10 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
result_out->settings.depth = settings.depth; result_out->settings.depth = settings.depth;
result_out->manager = std::move(manager); result_out->manager = std::move(manager);
result_out->end = state.block_info.back().end + 1; result_out->end = state.block_info.back().end + 1;
return std::move(result_out); return result_out;
} }
} }
result_out->start = start_address; result_out->start = start_address;
result_out->settings.depth = result_out->settings.depth =
use_flow_stack ? CompileDepth::FlowStack : CompileDepth::NoFlowStack; use_flow_stack ? CompileDepth::FlowStack : CompileDepth::NoFlowStack;
@ -557,8 +558,9 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
} }
if (!use_flow_stack) { if (!use_flow_stack) {
result_out->labels = std::move(state.labels); result_out->labels = std::move(state.labels);
return std::move(result_out); return result_out;
} }
auto back = result_out->blocks.begin(); auto back = result_out->blocks.begin();
auto next = std::next(back); auto next = std::next(back);
while (next != result_out->blocks.end()) { while (next != result_out->blocks.end()) {
@ -570,6 +572,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
back = next; back = next;
++next; ++next;
} }
return std::move(result_out);
return result_out;
} }
} // namespace VideoCommon::Shader } // namespace VideoCommon::Shader