reduce: miscellaneous fixes (#2494)
* Fix .gitignore * Add missing reduction pass: RemoveBlockReductionOpportunityFinder * Add DumpShader functions in test_reduce for debugging * Add DumpShader functions in spirv-reduce for debugging * Fix include style * Don't use "using namespace"
This commit is contained in:
Родитель
7ce37d66a8
Коммит
d90aae9a5a
|
@ -21,5 +21,5 @@ compile_commands.json
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# C-Lion
|
# C-Lion
|
||||||
.idea
|
/.idea/
|
||||||
cmake-build-debug
|
/cmake-build-*/
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "change_operand_reduction_opportunity.h"
|
#include "source/reduce/change_operand_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -15,22 +15,20 @@
|
||||||
#ifndef SOURCE_REDUCE_CHANGE_OPERAND_REDUCTION_OPPORTUNITY_H_
|
#ifndef SOURCE_REDUCE_CHANGE_OPERAND_REDUCTION_OPPORTUNITY_H_
|
||||||
#define SOURCE_REDUCE_CHANGE_OPERAND_REDUCTION_OPPORTUNITY_H_
|
#define SOURCE_REDUCE_CHANGE_OPERAND_REDUCTION_OPPORTUNITY_H_
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
|
||||||
#include "source/opt/instruction.h"
|
#include "source/opt/instruction.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "spirv-tools/libspirv.h"
|
#include "spirv-tools/libspirv.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
|
||||||
|
|
||||||
// An opportunity to replace an id operand of an instruction with some other id.
|
// An opportunity to replace an id operand of an instruction with some other id.
|
||||||
class ChangeOperandReductionOpportunity : public ReductionOpportunity {
|
class ChangeOperandReductionOpportunity : public ReductionOpportunity {
|
||||||
public:
|
public:
|
||||||
// Constructs the opportunity to replace operand |operand_index| of |inst|
|
// Constructs the opportunity to replace operand |operand_index| of |inst|
|
||||||
// with |new_id|.
|
// with |new_id|.
|
||||||
ChangeOperandReductionOpportunity(Instruction* inst, uint32_t operand_index,
|
ChangeOperandReductionOpportunity(opt::Instruction* inst,
|
||||||
uint32_t new_id)
|
uint32_t operand_index, uint32_t new_id)
|
||||||
: inst_(inst),
|
: inst_(inst),
|
||||||
operand_index_(operand_index),
|
operand_index_(operand_index),
|
||||||
original_id_(inst->GetOperand(operand_index).words[0]),
|
original_id_(inst->GetOperand(operand_index).words[0]),
|
||||||
|
@ -43,7 +41,7 @@ class ChangeOperandReductionOpportunity : public ReductionOpportunity {
|
||||||
void Apply() override;
|
void Apply() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Instruction* const inst_;
|
opt::Instruction* const inst_;
|
||||||
const uint32_t operand_index_;
|
const uint32_t operand_index_;
|
||||||
const uint32_t original_id_;
|
const uint32_t original_id_;
|
||||||
const spv_operand_type_t original_type_;
|
const spv_operand_type_t original_type_;
|
||||||
|
|
|
@ -12,15 +12,17 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "merge_blocks_reduction_opportunity.h"
|
#include "source/reduce/merge_blocks_reduction_opportunity.h"
|
||||||
#include "source/opt/block_merge_util.h"
|
|
||||||
|
|
||||||
|
#include "source/opt/block_merge_util.h"
|
||||||
#include "source/opt/ir_context.h"
|
#include "source/opt/ir_context.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::BasicBlock;
|
||||||
|
using opt::Function;
|
||||||
|
using opt::IRContext;
|
||||||
|
|
||||||
MergeBlocksReductionOpportunity::MergeBlocksReductionOpportunity(
|
MergeBlocksReductionOpportunity::MergeBlocksReductionOpportunity(
|
||||||
IRContext* context, Function* function, BasicBlock* block) {
|
IRContext* context, Function* function, BasicBlock* block) {
|
||||||
|
@ -48,7 +50,8 @@ bool MergeBlocksReductionOpportunity::PreconditionHolds() {
|
||||||
"predecessor must be present.");
|
"predecessor must be present.");
|
||||||
const uint32_t predecessor_id = predecessors[0];
|
const uint32_t predecessor_id = predecessors[0];
|
||||||
BasicBlock* predecessor_block = context_->get_instr_block(predecessor_id);
|
BasicBlock* predecessor_block = context_->get_instr_block(predecessor_id);
|
||||||
return blockmergeutil::CanMergeWithSuccessor(context_, predecessor_block);
|
return opt::blockmergeutil::CanMergeWithSuccessor(context_,
|
||||||
|
predecessor_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeBlocksReductionOpportunity::Apply() {
|
void MergeBlocksReductionOpportunity::Apply() {
|
||||||
|
@ -65,7 +68,7 @@ void MergeBlocksReductionOpportunity::Apply() {
|
||||||
// We need an iterator pointing to the predecessor, hence the loop.
|
// We need an iterator pointing to the predecessor, hence the loop.
|
||||||
for (auto bi = function_->begin(); bi != function_->end(); ++bi) {
|
for (auto bi = function_->begin(); bi != function_->end(); ++bi) {
|
||||||
if (bi->id() == predecessor_id) {
|
if (bi->id() == predecessor_id) {
|
||||||
blockmergeutil::MergeWithSuccessor(context_, function_, bi);
|
opt::blockmergeutil::MergeWithSuccessor(context_, function_, bi);
|
||||||
// Block merging changes the control flow graph, so invalidate it.
|
// Block merging changes the control flow graph, so invalidate it.
|
||||||
context_->InvalidateAnalysesExceptFor(IRContext::Analysis::kAnalysisNone);
|
context_->InvalidateAnalysesExceptFor(IRContext::Analysis::kAnalysisNone);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
#ifndef SOURCE_REDUCE_MERGE_BLOCKS_REDUCTION_OPPORTUNITY_H_
|
#ifndef SOURCE_REDUCE_MERGE_BLOCKS_REDUCTION_OPPORTUNITY_H_
|
||||||
#define SOURCE_REDUCE_MERGE_BLOCKS_REDUCTION_OPPORTUNITY_H_
|
#define SOURCE_REDUCE_MERGE_BLOCKS_REDUCTION_OPPORTUNITY_H_
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
|
||||||
#include "source/opt/basic_block.h"
|
#include "source/opt/basic_block.h"
|
||||||
#include "source/opt/function.h"
|
#include "source/opt/function.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
|
||||||
std::string MergeBlocksReductionOpportunityFinder::GetName() const {
|
std::string MergeBlocksReductionOpportunityFinder::GetName() const {
|
||||||
return "MergeBlocksReductionOpportunityFinder";
|
return "MergeBlocksReductionOpportunityFinder";
|
||||||
|
@ -27,14 +27,14 @@ std::string MergeBlocksReductionOpportunityFinder::GetName() const {
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
MergeBlocksReductionOpportunityFinder::GetAvailableOpportunities(
|
MergeBlocksReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
|
|
||||||
// Consider every block in every function.
|
// Consider every block in every function.
|
||||||
for (auto& function : *context->module()) {
|
for (auto& function : *context->module()) {
|
||||||
for (auto& block : function) {
|
for (auto& block : function) {
|
||||||
// See whether it is possible to merge this block with its successor.
|
// See whether it is possible to merge this block with its successor.
|
||||||
if (blockmergeutil::CanMergeWithSuccessor(context, &block)) {
|
if (opt::blockmergeutil::CanMergeWithSuccessor(context, &block)) {
|
||||||
// It is, so record an opportunity to do this.
|
// It is, so record an opportunity to do this.
|
||||||
result.push_back(spvtools::MakeUnique<MergeBlocksReductionOpportunity>(
|
result.push_back(spvtools::MakeUnique<MergeBlocksReductionOpportunity>(
|
||||||
context, &function, &block));
|
context, &function, &block));
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
OperandToConstReductionOpportunityFinder::GetAvailableOpportunities(
|
OperandToConstReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
assert(result.empty());
|
assert(result.empty());
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,21 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "operand_to_dominating_id_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h"
|
||||||
#include "change_operand_reduction_opportunity.h"
|
|
||||||
#include "source/opt/instruction.h"
|
#include "source/opt/instruction.h"
|
||||||
|
#include "source/reduce/change_operand_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::Function;
|
||||||
|
using opt::IRContext;
|
||||||
|
using opt::Instruction;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
OperandToDominatingIdReductionOpportunityFinder::GetAvailableOpportunities(
|
OperandToDominatingIdReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
|
|
||||||
// Go through every instruction in every block, considering it as a potential
|
// Go through every instruction in every block, considering it as a potential
|
||||||
|
@ -58,9 +61,9 @@ OperandToDominatingIdReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
void OperandToDominatingIdReductionOpportunityFinder::
|
void OperandToDominatingIdReductionOpportunityFinder::
|
||||||
GetOpportunitiesForDominatingInst(
|
GetOpportunitiesForDominatingInst(
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>* opportunities,
|
std::vector<std::unique_ptr<ReductionOpportunity>>* opportunities,
|
||||||
opt::Instruction* candidate_dominator,
|
Instruction* candidate_dominator,
|
||||||
opt::Function::iterator candidate_dominator_block,
|
Function::iterator candidate_dominator_block, Function* function,
|
||||||
opt::Function* function, opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
assert(candidate_dominator->HasResultId());
|
assert(candidate_dominator->HasResultId());
|
||||||
assert(candidate_dominator->type_id());
|
assert(candidate_dominator->type_id());
|
||||||
auto dominator_analysis = context->GetDominatorAnalysis(function);
|
auto dominator_analysis = context->GetDominatorAnalysis(function);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SOURCE_REDUCE_OPERAND_TO_DOMINATING_ID_REDUCTION_OPPORTUNITY_FINDER_H_
|
#ifndef SOURCE_REDUCE_OPERAND_TO_DOMINATING_ID_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
#define SOURCE_REDUCE_OPERAND_TO_DOMINATING_ID_REDUCTION_OPPORTUNITY_FINDER_H_
|
#define SOURCE_REDUCE_OPERAND_TO_DOMINATING_ID_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
|
|
||||||
#include "reduction_opportunity_finder.h"
|
#include "source/reduce/reduction_opportunity_finder.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
OperandToUndefReductionOpportunityFinder::GetAvailableOpportunities(
|
OperandToUndefReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "source/reduce/reducer.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -19,6 +21,7 @@
|
||||||
#include "source/reduce/operand_to_const_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_const_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/operand_to_undef_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_undef_reduction_opportunity_finder.h"
|
||||||
|
#include "source/reduce/remove_block_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/remove_function_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_function_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/remove_selection_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_selection_reduction_opportunity_finder.h"
|
||||||
|
@ -26,8 +29,6 @@
|
||||||
#include "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h"
|
#include "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h"
|
||||||
#include "source/spirv_reducer_options.h"
|
#include "source/spirv_reducer_options.h"
|
||||||
|
|
||||||
#include "reducer.h"
|
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
|
@ -186,6 +187,8 @@ void Reducer::AddDefaultReductionPasses() {
|
||||||
spvtools::MakeUnique<MergeBlocksReductionOpportunityFinder>());
|
spvtools::MakeUnique<MergeBlocksReductionOpportunityFinder>());
|
||||||
AddReductionPass(
|
AddReductionPass(
|
||||||
spvtools::MakeUnique<RemoveFunctionReductionOpportunityFinder>());
|
spvtools::MakeUnique<RemoveFunctionReductionOpportunityFinder>());
|
||||||
|
AddReductionPass(
|
||||||
|
spvtools::MakeUnique<RemoveBlockReductionOpportunityFinder>());
|
||||||
AddReductionPass(
|
AddReductionPass(
|
||||||
spvtools::MakeUnique<RemoveSelectionReductionOpportunityFinder>());
|
spvtools::MakeUnique<RemoveSelectionReductionOpportunityFinder>());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "source/reduce/reduction_pass.h"
|
||||||
#include "spirv-tools/libspirv.hpp"
|
#include "spirv-tools/libspirv.hpp"
|
||||||
|
|
||||||
#include "reduction_pass.h"
|
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#ifndef SOURCE_REDUCE_REDUCTION_OPPORTUNITY_FINDER_H_
|
#ifndef SOURCE_REDUCE_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
#define SOURCE_REDUCE_REDUCTION_OPPORTUNITY_FINDER_H_
|
#define SOURCE_REDUCE_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
|
||||||
#include "source/opt/ir_context.h"
|
#include "source/opt/ir_context.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <algorithm>
|
#include "source/reduce/reduction_pass.h"
|
||||||
|
|
||||||
#include "reduction_pass.h"
|
#include <algorithm>
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
using opt::Instruction;
|
||||||
|
|
||||||
uint32_t FindOrCreateGlobalUndef(IRContext* context, uint32_t type_id) {
|
uint32_t FindOrCreateGlobalUndef(IRContext* context, uint32_t type_id) {
|
||||||
for (auto& inst : context->module()->types_values()) {
|
for (auto& inst : context->module()->types_values()) {
|
||||||
|
|
|
@ -12,14 +12,15 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "remove_block_reduction_opportunity.h"
|
#include "source/reduce/remove_block_reduction_opportunity.h"
|
||||||
|
|
||||||
#include "source/opt/ir_context.h"
|
#include "source/opt/ir_context.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::BasicBlock;
|
||||||
|
using opt::Function;
|
||||||
|
|
||||||
RemoveBlockReductionOpportunity::RemoveBlockReductionOpportunity(
|
RemoveBlockReductionOpportunity::RemoveBlockReductionOpportunity(
|
||||||
Function* function, BasicBlock* block)
|
Function* function, BasicBlock* block)
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
#ifndef SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_
|
#ifndef SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_
|
||||||
#define SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_
|
#define SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
|
||||||
#include "source/opt/basic_block.h"
|
#include "source/opt/basic_block.h"
|
||||||
#include "source/opt/function.h"
|
#include "source/opt/function.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -13,12 +13,15 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "source/reduce/remove_block_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_block_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
#include "source/reduce/remove_block_reduction_opportunity.h"
|
#include "source/reduce/remove_block_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::Function;
|
||||||
|
using opt::IRContext;
|
||||||
|
using opt::Instruction;
|
||||||
|
|
||||||
std::string RemoveBlockReductionOpportunityFinder::GetName() const {
|
std::string RemoveBlockReductionOpportunityFinder::GetName() const {
|
||||||
return "RemoveBlockReductionOpportunityFinder";
|
return "RemoveBlockReductionOpportunityFinder";
|
||||||
|
@ -26,7 +29,7 @@ std::string RemoveBlockReductionOpportunityFinder::GetName() const {
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
RemoveBlockReductionOpportunityFinder::GetAvailableOpportunities(
|
RemoveBlockReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
|
|
||||||
// Consider every block in every function.
|
// Consider every block in every function.
|
||||||
|
@ -42,8 +45,7 @@ RemoveBlockReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoveBlockReductionOpportunityFinder::IsBlockValidOpportunity(
|
bool RemoveBlockReductionOpportunityFinder::IsBlockValidOpportunity(
|
||||||
opt::IRContext* context, opt::Function& function,
|
IRContext* context, Function& function, Function::iterator& bi) {
|
||||||
opt::Function::iterator& bi) {
|
|
||||||
assert(bi != function.end() && "Block iterator was out of bounds");
|
assert(bi != function.end() && "Block iterator was out of bounds");
|
||||||
|
|
||||||
// Don't remove first block; we don't want to end up with no blocks.
|
// Don't remove first block; we don't want to end up with no blocks.
|
||||||
|
@ -65,7 +67,7 @@ bool RemoveBlockReductionOpportunityFinder::IsBlockValidOpportunity(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoveBlockReductionOpportunityFinder::
|
bool RemoveBlockReductionOpportunityFinder::
|
||||||
BlockInstructionsHaveNoOutsideReferences(opt::IRContext* context,
|
BlockInstructionsHaveNoOutsideReferences(IRContext* context,
|
||||||
const Function::iterator& bi) {
|
const Function::iterator& bi) {
|
||||||
// Get all instructions in block.
|
// Get all instructions in block.
|
||||||
std::unordered_set<uint32_t> instructions_in_block;
|
std::unordered_set<uint32_t> instructions_in_block;
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "remove_function_reduction_opportunity.h"
|
#include "source/reduce/remove_function_reduction_opportunity.h"
|
||||||
|
|
||||||
#include "source/opt/eliminate_dead_functions_util.h"
|
#include "source/opt/eliminate_dead_functions_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#ifndef SOURCE_REDUCE_REMOVE_FUNCTION_REDUCTION_OPPORTUNITY_H_
|
#ifndef SOURCE_REDUCE_REMOVE_FUNCTION_REDUCTION_OPPORTUNITY_H_
|
||||||
#define SOURCE_REDUCE_REMOVE_FUNCTION_REDUCTION_OPPORTUNITY_H_
|
#define SOURCE_REDUCE_REMOVE_FUNCTION_REDUCTION_OPPORTUNITY_H_
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
|
||||||
#include "source/opt/function.h"
|
#include "source/opt/function.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,8 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "remove_function_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_function_reduction_opportunity_finder.h"
|
||||||
#include "remove_function_reduction_opportunity.h"
|
|
||||||
|
#include "source/reduce/remove_function_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "source/opt/ir_context.h"
|
#include "source/reduce/remove_instruction_reduction_opportunity.h"
|
||||||
|
|
||||||
#include "remove_instruction_reduction_opportunity.h"
|
#include "source/opt/ir_context.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -15,19 +15,17 @@
|
||||||
#ifndef SOURCE_REDUCE_REMOVE_INSTRUCTION_REDUCTION_OPPORTUNITY_H_
|
#ifndef SOURCE_REDUCE_REMOVE_INSTRUCTION_REDUCTION_OPPORTUNITY_H_
|
||||||
#define SOURCE_REDUCE_REMOVE_INSTRUCTION_REDUCTION_OPPORTUNITY_H_
|
#define SOURCE_REDUCE_REMOVE_INSTRUCTION_REDUCTION_OPPORTUNITY_H_
|
||||||
|
|
||||||
#include "reduction_opportunity.h"
|
|
||||||
#include "source/opt/instruction.h"
|
#include "source/opt/instruction.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
|
||||||
|
|
||||||
// An opportunity to remove an instruction from the SPIR-V module.
|
// An opportunity to remove an instruction from the SPIR-V module.
|
||||||
class RemoveInstructionReductionOpportunity : public ReductionOpportunity {
|
class RemoveInstructionReductionOpportunity : public ReductionOpportunity {
|
||||||
public:
|
public:
|
||||||
// Constructs the opportunity to remove |inst|.
|
// Constructs the opportunity to remove |inst|.
|
||||||
explicit RemoveInstructionReductionOpportunity(Instruction* inst)
|
explicit RemoveInstructionReductionOpportunity(opt::Instruction* inst)
|
||||||
: inst_(inst) {}
|
: inst_(inst) {}
|
||||||
|
|
||||||
// Always returns true, as this opportunity can always be applied.
|
// Always returns true, as this opportunity can always be applied.
|
||||||
|
@ -37,7 +35,7 @@ class RemoveInstructionReductionOpportunity : public ReductionOpportunity {
|
||||||
void Apply() override;
|
void Apply() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Instruction* inst_;
|
opt::Instruction* inst_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace reduce
|
} // namespace reduce
|
||||||
|
|
|
@ -12,19 +12,20 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "remove_opname_instruction_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
||||||
#include "remove_instruction_reduction_opportunity.h"
|
|
||||||
#include "source/opcode.h"
|
#include "source/opcode.h"
|
||||||
#include "source/opt/instruction.h"
|
#include "source/opt/instruction.h"
|
||||||
|
#include "source/reduce/remove_instruction_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
RemoveOpNameInstructionReductionOpportunityFinder::GetAvailableOpportunities(
|
RemoveOpNameInstructionReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
|
|
||||||
for (auto& inst : context->module()->debugs2()) {
|
for (auto& inst : context->module()->debugs2()) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SOURCE_REDUCE_REMOVE_OPNAME_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
#ifndef SOURCE_REDUCE_REMOVE_OPNAME_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
#define SOURCE_REDUCE_REMOVE_OPNAME_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
#define SOURCE_REDUCE_REMOVE_OPNAME_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
|
|
||||||
#include "reduction_opportunity_finder.h"
|
#include "source/reduce/reduction_opportunity_finder.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::BasicBlock;
|
||||||
|
using opt::IRContext;
|
||||||
|
using opt::Instruction;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const uint32_t kMergeNodeIndex = 0;
|
const uint32_t kMergeNodeIndex = 0;
|
||||||
|
@ -32,7 +34,7 @@ std::string RemoveSelectionReductionOpportunityFinder::GetName() const {
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
RemoveSelectionReductionOpportunityFinder::GetAvailableOpportunities(
|
RemoveSelectionReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
// Get all loop merge and continue blocks so we can check for these later.
|
// Get all loop merge and continue blocks so we can check for these later.
|
||||||
std::unordered_set<uint32_t> merge_and_continue_blocks_from_loops;
|
std::unordered_set<uint32_t> merge_and_continue_blocks_from_loops;
|
||||||
for (auto& function : *context->module()) {
|
for (auto& function : *context->module()) {
|
||||||
|
@ -71,8 +73,8 @@ RemoveSelectionReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoveSelectionReductionOpportunityFinder::CanOpSelectionMergeBeRemoved(
|
bool RemoveSelectionReductionOpportunityFinder::CanOpSelectionMergeBeRemoved(
|
||||||
opt::IRContext* context, const opt::BasicBlock& header_block,
|
IRContext* context, const BasicBlock& header_block,
|
||||||
opt::Instruction* merge_instruction,
|
Instruction* merge_instruction,
|
||||||
std::unordered_set<uint32_t> merge_and_continue_blocks_from_loops) {
|
std::unordered_set<uint32_t> merge_and_continue_blocks_from_loops) {
|
||||||
assert(header_block.GetMergeInst() == merge_instruction &&
|
assert(header_block.GetMergeInst() == merge_instruction &&
|
||||||
"CanOpSelectionMergeBeRemoved(...): header block and merge "
|
"CanOpSelectionMergeBeRemoved(...): header block and merge "
|
||||||
|
|
|
@ -12,19 +12,20 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "remove_unreferenced_instruction_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h"
|
||||||
#include "remove_instruction_reduction_opportunity.h"
|
|
||||||
#include "source/opcode.h"
|
#include "source/opcode.h"
|
||||||
#include "source/opt/instruction.h"
|
#include "source/opt/instruction.h"
|
||||||
|
#include "source/reduce/remove_instruction_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
RemoveUnreferencedInstructionReductionOpportunityFinder::
|
RemoveUnreferencedInstructionReductionOpportunityFinder::
|
||||||
GetAvailableOpportunities(opt::IRContext* context) const {
|
GetAvailableOpportunities(IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
|
|
||||||
for (auto& function : *context->module()) {
|
for (auto& function : *context->module()) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SOURCE_REDUCE_REMOVE_UNREFERENCED_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
#ifndef SOURCE_REDUCE_REMOVE_UNREFERENCED_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
#define SOURCE_REDUCE_REMOVE_UNREFERENCED_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
#define SOURCE_REDUCE_REMOVE_UNREFERENCED_INSTRUCTION_REDUCTION_OPPORTUNITY_FINDER_H_
|
||||||
|
|
||||||
#include "reduction_opportunity_finder.h"
|
#include "source/reduce/reduction_opportunity_finder.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
|
using opt::BasicBlock;
|
||||||
|
using opt::IRContext;
|
||||||
|
using opt::Instruction;
|
||||||
|
using opt::Operand;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const uint32_t kMergeNodeIndex = 0;
|
const uint32_t kMergeNodeIndex = 0;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -208,8 +213,8 @@ void StructuredLoopToSelectionReductionOpportunity::ChangeLoopToSelection() {
|
||||||
// the "else" branch be the merge block.
|
// the "else" branch be the merge block.
|
||||||
auto terminator = loop_construct_header_->terminator();
|
auto terminator = loop_construct_header_->terminator();
|
||||||
if (terminator->opcode() == SpvOpBranch) {
|
if (terminator->opcode() == SpvOpBranch) {
|
||||||
analysis::Bool temp;
|
opt::analysis::Bool temp;
|
||||||
const analysis::Bool* bool_type =
|
const opt::analysis::Bool* bool_type =
|
||||||
context_->get_type_mgr()->GetRegisteredType(&temp)->AsBool();
|
context_->get_type_mgr()->GetRegisteredType(&temp)->AsBool();
|
||||||
auto const_mgr = context_->get_constant_mgr();
|
auto const_mgr = context_->get_constant_mgr();
|
||||||
auto true_const = const_mgr->GetConstant(bool_type, {1});
|
auto true_const = const_mgr->GetConstant(bool_type, {1});
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
|
||||||
|
|
||||||
// An opportunity to replace a structured loop with a selection.
|
// An opportunity to replace a structured loop with a selection.
|
||||||
class StructuredLoopToSelectionReductionOpportunity
|
class StructuredLoopToSelectionReductionOpportunity
|
||||||
: public ReductionOpportunity {
|
: public ReductionOpportunity {
|
||||||
|
@ -32,8 +30,8 @@ class StructuredLoopToSelectionReductionOpportunity
|
||||||
// Constructs an opportunity from a loop header block and the function that
|
// Constructs an opportunity from a loop header block and the function that
|
||||||
// encloses it.
|
// encloses it.
|
||||||
explicit StructuredLoopToSelectionReductionOpportunity(
|
explicit StructuredLoopToSelectionReductionOpportunity(
|
||||||
IRContext* context, BasicBlock* loop_construct_header,
|
opt::IRContext* context, opt::BasicBlock* loop_construct_header,
|
||||||
Function* enclosing_function)
|
opt::Function* enclosing_function)
|
||||||
: context_(context),
|
: context_(context),
|
||||||
loop_construct_header_(loop_construct_header),
|
loop_construct_header_(loop_construct_header),
|
||||||
enclosing_function_(enclosing_function) {}
|
enclosing_function_(enclosing_function) {}
|
||||||
|
@ -67,11 +65,12 @@ class StructuredLoopToSelectionReductionOpportunity
|
||||||
// Removes any components of |to_block|'s phi instructions relating to
|
// Removes any components of |to_block|'s phi instructions relating to
|
||||||
// |from_id|.
|
// |from_id|.
|
||||||
void AdaptPhiInstructionsForRemovedEdge(uint32_t from_id,
|
void AdaptPhiInstructionsForRemovedEdge(uint32_t from_id,
|
||||||
BasicBlock* to_block);
|
opt::BasicBlock* to_block);
|
||||||
|
|
||||||
// Adds components to |to_block|'s phi instructions to account for a new
|
// Adds components to |to_block|'s phi instructions to account for a new
|
||||||
// incoming edge from |from_id|.
|
// incoming edge from |from_id|.
|
||||||
void AdaptPhiInstructionsForAddedEdge(uint32_t from_id, BasicBlock* to_block);
|
void AdaptPhiInstructionsForAddedEdge(uint32_t from_id,
|
||||||
|
opt::BasicBlock* to_block);
|
||||||
|
|
||||||
// Turns the OpLoopMerge for the loop into OpSelectionMerge, and adapts the
|
// Turns the OpLoopMerge for the loop into OpSelectionMerge, and adapts the
|
||||||
// following branch instruction accordingly.
|
// following branch instruction accordingly.
|
||||||
|
@ -87,9 +86,10 @@ class StructuredLoopToSelectionReductionOpportunity
|
||||||
// 2) |def| is an OpVariable
|
// 2) |def| is an OpVariable
|
||||||
// 3) |use| is part of an OpPhi, with associated incoming block b, and |def|
|
// 3) |use| is part of an OpPhi, with associated incoming block b, and |def|
|
||||||
// dominates b.
|
// dominates b.
|
||||||
bool DefinitionSufficientlyDominatesUse(Instruction* def, Instruction* use,
|
bool DefinitionSufficientlyDominatesUse(opt::Instruction* def,
|
||||||
|
opt::Instruction* use,
|
||||||
uint32_t use_index,
|
uint32_t use_index,
|
||||||
BasicBlock& def_block);
|
opt::BasicBlock& def_block);
|
||||||
|
|
||||||
// Checks whether the global value list has an OpVariable of the given pointer
|
// Checks whether the global value list has an OpVariable of the given pointer
|
||||||
// type, adding one if not, and returns the id of such an OpVariable.
|
// type, adding one if not, and returns the id of such an OpVariable.
|
||||||
|
@ -105,9 +105,9 @@ class StructuredLoopToSelectionReductionOpportunity
|
||||||
// be factored out in due course.
|
// be factored out in due course.
|
||||||
uint32_t FindOrCreateFunctionVariable(uint32_t pointer_type_id);
|
uint32_t FindOrCreateFunctionVariable(uint32_t pointer_type_id);
|
||||||
|
|
||||||
IRContext* context_;
|
opt::IRContext* context_;
|
||||||
BasicBlock* loop_construct_header_;
|
opt::BasicBlock* loop_construct_header_;
|
||||||
Function* enclosing_function_;
|
opt::Function* enclosing_function_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace reduce
|
} // namespace reduce
|
||||||
|
|
|
@ -12,13 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "structured_loop_to_selection_reduction_opportunity_finder.h"
|
#include "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h"
|
||||||
#include "structured_loop_to_selection_reduction_opportunity.h"
|
|
||||||
|
#include "source/reduce/structured_loop_to_selection_reduction_opportunity.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
using namespace opt;
|
using opt::IRContext;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const uint32_t kMergeNodeIndex = 0;
|
const uint32_t kMergeNodeIndex = 0;
|
||||||
|
@ -27,7 +28,7 @@ const uint32_t kContinueNodeIndex = 1;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>>
|
std::vector<std::unique_ptr<ReductionOpportunity>>
|
||||||
StructuredLoopToSelectionReductionOpportunityFinder::GetAvailableOpportunities(
|
StructuredLoopToSelectionReductionOpportunityFinder::GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const {
|
IRContext* context) const {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
|
|
||||||
std::set<uint32_t> merge_block_ids;
|
std::set<uint32_t> merge_block_ids;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SOURCE_REDUCE_STRUCTURED_LOOP_TO_SELECTION_REDUCTION_OPPORTUNITY_FINDER_H
|
#ifndef SOURCE_REDUCE_STRUCTURED_LOOP_TO_SELECTION_REDUCTION_OPPORTUNITY_FINDER_H
|
||||||
#define SOURCE_REDUCE_STRUCTURED_LOOP_TO_SELECTION_REDUCTION_OPPORTUNITY_FINDER_H
|
#define SOURCE_REDUCE_STRUCTURED_LOOP_TO_SELECTION_REDUCTION_OPPORTUNITY_FINDER_H
|
||||||
|
|
||||||
#include "reduction_opportunity_finder.h"
|
#include "source/reduce/reduction_opportunity_finder.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
|
||||||
#include "source/opt/build_module.h"
|
|
||||||
#include "source/reduce/merge_blocks_reduction_opportunity_finder.h"
|
#include "source/reduce/merge_blocks_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
|
#include "source/opt/build_module.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
|
||||||
#include "source/opt/build_module.h"
|
|
||||||
#include "source/reduce/operand_to_const_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_const_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
|
#include "source/opt/build_module.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
|
||||||
#include "source/opt/build_module.h"
|
|
||||||
#include "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
|
#include "source/opt/build_module.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
|
||||||
#include "source/reduce/operand_to_undef_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_undef_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
|
#include "source/opt/build_module.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "test/reduce/reduce_test_util.h"
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "tools/io.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
||||||
|
@ -92,5 +94,19 @@ void CLIMessageConsumer(spv_message_level_t level, const char*,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DumpShader(opt::IRContext* context, const char* filename) {
|
||||||
|
std::vector<uint32_t> binary;
|
||||||
|
context->module()->ToBinary(&binary, false);
|
||||||
|
DumpShader(binary, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DumpShader(const std::vector<uint32_t>& binary, const char* filename) {
|
||||||
|
auto write_file_succeeded =
|
||||||
|
WriteFile(filename, "wb", &binary[0], binary.size());
|
||||||
|
if (!write_file_succeeded) {
|
||||||
|
std::cerr << "Failed to dump shader" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace reduce
|
} // namespace reduce
|
||||||
} // namespace spvtools
|
} // namespace spvtools
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define TEST_REDUCE_REDUCE_TEST_UTIL_H_
|
#define TEST_REDUCE_REDUCE_TEST_UTIL_H_
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include "source/opt/ir_context.h"
|
#include "source/opt/ir_context.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "spirv-tools/libspirv.h"
|
#include "spirv-tools/libspirv.h"
|
||||||
|
@ -63,6 +62,13 @@ void NopDiagnostic(spv_message_level_t /*level*/, const char* /*source*/,
|
||||||
void CLIMessageConsumer(spv_message_level_t level, const char*,
|
void CLIMessageConsumer(spv_message_level_t level, const char*,
|
||||||
const spv_position_t& position, const char* message);
|
const spv_position_t& position, const char* message);
|
||||||
|
|
||||||
|
// Dumps the SPIRV-V module in |context| to file |filename|. Useful for
|
||||||
|
// interactive debugging.
|
||||||
|
void DumpShader(opt::IRContext* context, const char* filename);
|
||||||
|
|
||||||
|
// Dumps |binary| to file |filename|. Useful for interactive debugging.
|
||||||
|
void DumpShader(const std::vector<uint32_t>& binary, const char* filename);
|
||||||
|
|
||||||
} // namespace reduce
|
} // namespace reduce
|
||||||
} // namespace spvtools
|
} // namespace spvtools
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
#include "source/reduce/reducer.h"
|
||||||
|
|
||||||
#include "source/reduce/operand_to_const_reduction_opportunity_finder.h"
|
#include "source/reduce/operand_to_const_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/reducer.h"
|
|
||||||
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
||||||
#include "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h"
|
#include "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
#include "source/reduce/remove_block_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "source/reduce/remove_block_reduction_opportunity.h"
|
#include "test/reduce/reduce_test_util.h"
|
||||||
#include "source/reduce/remove_block_reduction_opportunity_finder.h"
|
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
#include "source/reduce/remove_function_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "source/reduce/remove_function_reduction_opportunity_finder.h"
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "source/reduce/reduction_pass.h"
|
#include "source/reduce/reduction_pass.h"
|
||||||
#include "source/reduce/remove_opname_instruction_reduction_opportunity_finder.h"
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "source/reduce/remove_selection_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "source/reduce/reduction_pass.h"
|
|
||||||
#include "source/reduce/remove_selection_reduction_opportunity_finder.h"
|
|
||||||
#include "test/reduce/reduce_test_util.h"
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
|
|
|
@ -12,13 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
#include "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
#include "source/reduce/reduction_opportunity.h"
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "source/reduce/reduction_pass.h"
|
|
||||||
#include "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h"
|
|
||||||
#include "source/util/make_unique.h"
|
#include "source/util/make_unique.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
|
||||||
#include "source/opt/build_module.h"
|
|
||||||
#include "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h"
|
#include "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h"
|
||||||
|
|
||||||
|
#include "source/opt/build_module.h"
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -12,16 +12,20 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "reduce_test_util.h"
|
|
||||||
|
|
||||||
#include "source/reduce/reducer.h"
|
#include "source/reduce/reducer.h"
|
||||||
#include "source/reduce/reduction_pass.h"
|
|
||||||
|
#include "source/reduce/reduction_opportunity.h"
|
||||||
#include "source/reduce/remove_instruction_reduction_opportunity.h"
|
#include "source/reduce/remove_instruction_reduction_opportunity.h"
|
||||||
|
#include "test/reduce/reduce_test_util.h"
|
||||||
|
|
||||||
namespace spvtools {
|
namespace spvtools {
|
||||||
namespace reduce {
|
namespace reduce {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using opt::Function;
|
||||||
|
using opt::IRContext;
|
||||||
|
using opt::Instruction;
|
||||||
|
|
||||||
// A dumb reduction opportunity finder that finds opportunities to remove global
|
// A dumb reduction opportunity finder that finds opportunities to remove global
|
||||||
// values regardless of whether they are referenced. This is very likely to make
|
// values regardless of whether they are referenced. This is very likely to make
|
||||||
// the resulting module invalid. We use this to test the reducer's behavior in
|
// the resulting module invalid. We use this to test the reducer's behavior in
|
||||||
|
@ -40,7 +44,7 @@ class BlindlyRemoveGlobalValuesReductionOpportunityFinder
|
||||||
// referenced (directly or indirectly) from elsewhere in the module, each such
|
// referenced (directly or indirectly) from elsewhere in the module, each such
|
||||||
// opportunity will make the module invalid.
|
// opportunity will make the module invalid.
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> GetAvailableOpportunities(
|
std::vector<std::unique_ptr<ReductionOpportunity>> GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const final {
|
IRContext* context) const final {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
for (auto& inst : context->module()->types_values()) {
|
for (auto& inst : context->module()->types_values()) {
|
||||||
if (inst.HasResultId()) {
|
if (inst.HasResultId()) {
|
||||||
|
@ -59,8 +63,8 @@ class BlindlyRemoveGlobalValuesReductionOpportunityFinder
|
||||||
// limits are enforced.
|
// limits are enforced.
|
||||||
class OpVariableDuplicatorReductionOpportunity : public ReductionOpportunity {
|
class OpVariableDuplicatorReductionOpportunity : public ReductionOpportunity {
|
||||||
public:
|
public:
|
||||||
OpVariableDuplicatorReductionOpportunity(Function* function_)
|
OpVariableDuplicatorReductionOpportunity(Function* function)
|
||||||
: function_(function_) {}
|
: function_(function) {}
|
||||||
|
|
||||||
bool PreconditionHolds() override {
|
bool PreconditionHolds() override {
|
||||||
Instruction* first_instruction = &*function_->begin()[0].begin();
|
Instruction* first_instruction = &*function_->begin()[0].begin();
|
||||||
|
@ -98,7 +102,7 @@ class OpVariableDuplicatorReductionOpportunityFinder
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> GetAvailableOpportunities(
|
std::vector<std::unique_ptr<ReductionOpportunity>> GetAvailableOpportunities(
|
||||||
opt::IRContext* context) const final {
|
IRContext* context) const final {
|
||||||
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
std::vector<std::unique_ptr<ReductionOpportunity>> result;
|
||||||
for (auto& function : *context->module()) {
|
for (auto& function : *context->module()) {
|
||||||
Instruction* first_instruction = &*function.begin()[0].begin();
|
Instruction* first_instruction = &*function.begin()[0].begin();
|
||||||
|
@ -446,7 +450,7 @@ TEST(ValidationDuringReductionTest, CheckNotAlwaysInvalidCanMakeProgress) {
|
||||||
|
|
||||||
// Sets up a Reducer for use in the CheckValidationOptions test; avoids
|
// Sets up a Reducer for use in the CheckValidationOptions test; avoids
|
||||||
// repetition.
|
// repetition.
|
||||||
void setupReducerForCheckValidationOptions(Reducer* reducer) {
|
void SetupReducerForCheckValidationOptions(Reducer* reducer) {
|
||||||
reducer->SetMessageConsumer(NopDiagnostic);
|
reducer->SetMessageConsumer(NopDiagnostic);
|
||||||
|
|
||||||
// Say that every module is interesting.
|
// Say that every module is interesting.
|
||||||
|
@ -531,7 +535,7 @@ TEST(ValidationDuringReductionTest, CheckValidationOptions) {
|
||||||
// always returns true.
|
// always returns true.
|
||||||
{
|
{
|
||||||
Reducer reducer(env);
|
Reducer reducer(env);
|
||||||
setupReducerForCheckValidationOptions(&reducer);
|
SetupReducerForCheckValidationOptions(&reducer);
|
||||||
|
|
||||||
Reducer::ReductionResultStatus status =
|
Reducer::ReductionResultStatus status =
|
||||||
reducer.Run(std::vector<uint32_t>(binary_in), &binary_out,
|
reducer.Run(std::vector<uint32_t>(binary_in), &binary_out,
|
||||||
|
@ -547,7 +551,7 @@ TEST(ValidationDuringReductionTest, CheckValidationOptions) {
|
||||||
// test always succeeds, and the finder yields infinite opportunities.
|
// test always succeeds, and the finder yields infinite opportunities.
|
||||||
{
|
{
|
||||||
Reducer reducer(env);
|
Reducer reducer(env);
|
||||||
setupReducerForCheckValidationOptions(&reducer);
|
SetupReducerForCheckValidationOptions(&reducer);
|
||||||
|
|
||||||
Reducer::ReductionResultStatus status =
|
Reducer::ReductionResultStatus status =
|
||||||
reducer.Run(std::vector<uint32_t>(binary_in), &binary_out,
|
reducer.Run(std::vector<uint32_t>(binary_in), &binary_out,
|
||||||
|
@ -565,7 +569,7 @@ TEST(ValidationDuringReductionTest, CheckValidationOptions) {
|
||||||
// validator limits.
|
// validator limits.
|
||||||
{
|
{
|
||||||
Reducer reducer(env);
|
Reducer reducer(env);
|
||||||
setupReducerForCheckValidationOptions(&reducer);
|
SetupReducerForCheckValidationOptions(&reducer);
|
||||||
|
|
||||||
Reducer::ReductionResultStatus status =
|
Reducer::ReductionResultStatus status =
|
||||||
reducer.Run(std::vector<uint32_t>(binary_in), &binary_out,
|
reducer.Run(std::vector<uint32_t>(binary_in), &binary_out,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
|
#include "source/opt/ir_context.h"
|
||||||
#include "source/opt/log.h"
|
#include "source/opt/log.h"
|
||||||
#include "source/reduce/reducer.h"
|
#include "source/reduce/reducer.h"
|
||||||
#include "source/spirv_reducer_options.h"
|
#include "source/spirv_reducer_options.h"
|
||||||
|
@ -25,8 +26,6 @@
|
||||||
#include "tools/io.h"
|
#include "tools/io.h"
|
||||||
#include "tools/util/cli_consumer.h"
|
#include "tools/util/cli_consumer.h"
|
||||||
|
|
||||||
using namespace spvtools::reduce;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ErrorOrInt = std::pair<std::string, int>;
|
using ErrorOrInt = std::pair<std::string, int>;
|
||||||
|
@ -200,6 +199,23 @@ ReduceStatus ParseFlags(int argc, const char** argv, const char** in_file,
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
// Dumps |binary| to file |filename|. Useful for interactive debugging.
|
||||||
|
void DumpShader(const std::vector<uint32_t>& binary, const char* filename) {
|
||||||
|
auto write_file_succeeded =
|
||||||
|
WriteFile(filename, "wb", &binary[0], binary.size());
|
||||||
|
if (!write_file_succeeded) {
|
||||||
|
std::cerr << "Failed to dump shader" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dumps the SPIRV-V module in |context| to file |filename|. Useful for
|
||||||
|
// interactive debugging.
|
||||||
|
void DumpShader(spvtools::opt::IRContext* context, const char* filename) {
|
||||||
|
std::vector<uint32_t> binary;
|
||||||
|
context->module()->ToBinary(&binary, false);
|
||||||
|
DumpShader(binary, filename);
|
||||||
|
}
|
||||||
|
|
||||||
const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_3;
|
const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_3;
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
int main(int argc, const char** argv) {
|
||||||
|
@ -223,7 +239,7 @@ int main(int argc, const char** argv) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reducer reducer(target_env);
|
spvtools::reduce::Reducer reducer(target_env);
|
||||||
|
|
||||||
reducer.SetInterestingnessFunction(
|
reducer.SetInterestingnessFunction(
|
||||||
[interestingness_test](std::vector<uint32_t> binary,
|
[interestingness_test](std::vector<uint32_t> binary,
|
||||||
|
@ -254,8 +270,8 @@ int main(int argc, const char** argv) {
|
||||||
const auto reduction_status = reducer.Run(std::move(binary_in), &binary_out,
|
const auto reduction_status = reducer.Run(std::move(binary_in), &binary_out,
|
||||||
reducer_options, validator_options);
|
reducer_options, validator_options);
|
||||||
|
|
||||||
if (reduction_status ==
|
if (reduction_status == spvtools::reduce::Reducer::ReductionResultStatus::
|
||||||
Reducer::ReductionResultStatus::kInitialStateNotInteresting ||
|
kInitialStateNotInteresting ||
|
||||||
!WriteFile<uint32_t>("_reduced_final.spv", "wb", binary_out.data(),
|
!WriteFile<uint32_t>("_reduced_final.spv", "wb", binary_out.data(),
|
||||||
binary_out.size())) {
|
binary_out.size())) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче