SPIRV-Tools/source/opt
Steven Perron 94af58a350 Clean up variables before sroa
In some shaders there are a lot of very large and deeply nested
structures.  This creates a lot of work for scalar replacement.  Also,
since commit ca4457b we have been very aggressive as rewriting
variables.  This has causes a large increase in compile time in creating
and then deleting the instructions.

To help low the costs, I want to run a cleanup of some of the easy loads
and stores to remove.  This reduces the number of symbols sroa has to
work on.  It also reduces the amount of code the simplifier has to
simplify because it was not generated by sroa.

To confirm the improvement, I ran numbers on three different sets of
shaders:

Time to run --legalize-hlsl:

Set #1: 55.89s -> 12.0s
Set #2: 1m44s -> 1m40.5s
Set #3: 6.8s -> 5.7s

Time to run -O

Set #1: 18.8s -> 10.9s
Set #2: 5m44s -> 4m17s
Set #3: 7.8s -> 7.8s

Contributes to #1328.
2018-02-22 21:40:58 -05:00
..
aggressive_dead_code_elim_pass.cpp Fixes infinite loop in ADCE 2018-01-19 11:08:46 -05:00
aggressive_dead_code_elim_pass.h Fixes infinite loop in ADCE 2018-01-19 11:08:46 -05:00
basic_block.cpp Add LoopUtils class to gather some loop transformation support. 2018-02-01 15:35:09 -05:00
basic_block.h Add LoopUtils class to gather some loop transformation support. 2018-02-01 15:35:09 -05:00
block_merge_pass.cpp Enhancements to block merging 2018-01-30 16:05:51 -05:00
block_merge_pass.h Enhancements to block merging 2018-01-30 16:05:51 -05:00
build_module.cpp Store all enabled capabilities in the feature manger. 2017-12-21 11:14:53 -05:00
build_module.h Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
ccp_pass.cpp Fixes #1338. Handle OpConstantNull in branch/switch conditions 2018-02-21 10:22:39 -05:00
ccp_pass.h Fix constant propagation of induction variables. 2018-01-08 15:34:35 -05:00
cfg_cleanup_pass.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
cfg_cleanup_pass.h Have all MemPasses preserve the def-use manager. 2017-11-10 11:17:12 -05:00
cfg.cpp Loop invariant code motion initial implementation 2018-02-08 22:55:47 -05:00
cfg.h Make use of the instruction folder. 2018-02-07 23:01:47 -05:00
CMakeLists.txt Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
common_uniform_elim_pass.cpp Disambiguate between const and nonconst ForEachSuccessorLabel 2018-02-02 17:54:40 -05:00
common_uniform_elim_pass.h Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
compact_ids_pass.cpp Add a new constant manager class. 2017-12-08 14:14:55 -05:00
compact_ids_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
composite.cpp InsertExtractElim: Split out DeadInsertElim as separate pass 2018-01-30 08:52:14 -05:00
composite.h InsertExtractElim: Split out DeadInsertElim as separate pass 2018-01-30 08:52:14 -05:00
const_folding_rules.cpp Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
const_folding_rules.h Fix spirv.h include to rely on include paths 2018-02-09 18:29:17 -08:00
constants.cpp Remove constants from constant manager in KillInst 2018-02-16 20:37:12 -05:00
constants.h Remove constants from constant manager in KillInst 2018-02-16 20:37:12 -05:00
dead_branch_elim_pass.cpp Simplify OpPhi instructions referencing unreachable continues 2018-02-16 18:58:03 -05:00
dead_branch_elim_pass.h Rewriting dead branch elimination. 2018-01-09 12:21:39 -05:00
dead_insert_elim_pass.cpp InsertExtractElim: Split out DeadInsertElim as separate pass 2018-01-30 08:52:14 -05:00
dead_insert_elim_pass.h Make use of the instruction folder. 2018-02-07 23:01:47 -05:00
dead_variable_elimination.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
dead_variable_elimination.h Have all MemPasses preserve the def-use manager. 2017-11-10 11:17:12 -05:00
decoration_manager.cpp Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
decoration_manager.h Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
def_use_manager.cpp Preserve analysies in the simplification pass 2018-02-22 16:06:30 -05:00
def_use_manager.h Add folding of OpCompositeExtract and OpConstantComposite constant instructions. 2018-02-09 17:52:33 -05:00
dominator_analysis.cpp Initial implementation of if conversion 2018-01-25 09:42:00 -08:00
dominator_analysis.h Initial implementation of if conversion 2018-01-25 09:42:00 -08:00
dominator_tree.cpp Disambiguate between const and nonconst ForEachSuccessorLabel 2018-02-02 17:54:40 -05:00
dominator_tree.h Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
eliminate_dead_constant_pass.cpp Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
eliminate_dead_constant_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
eliminate_dead_functions_pass.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
eliminate_dead_functions_pass.h Have all MemPasses preserve the def-use manager. 2017-11-10 11:17:12 -05:00
feature_manager.cpp Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
feature_manager.h Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
flatten_decoration_pass.cpp Adding an unique id to Instruction generated by IRContext 2017-11-20 17:49:10 -05:00
flatten_decoration_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
fold_spec_constant_op_and_composite_pass.cpp Implement SSA CCP (SSA Conditional Constant Propagation). 2017-12-21 14:29:45 -05:00
fold_spec_constant_op_and_composite_pass.h Improving the usability of the type manager. The type manager hashes 2017-12-18 08:20:56 -05:00
fold.cpp Get CCP to use the constant floating point rules. 2018-02-16 13:49:47 -05:00
fold.h Get CCP to use the constant floating point rules. 2018-02-16 13:49:47 -05:00
folding_rules.cpp Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
folding_rules.h Add folding of OpCompositeExtract and OpConstantComposite constant instructions. 2018-02-09 17:52:33 -05:00
freeze_spec_constant_value_pass.cpp Replace calls to ToNop by KillInst. 2018-01-04 11:03:04 -05:00
freeze_spec_constant_value_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
function.cpp Adding ostream operators for IR structures 2018-01-12 11:19:58 -05:00
function.h Adding ostream operators for IR structures 2018-01-12 11:19:58 -05:00
if_conversion.cpp Remove constexpr from Analysis operators 2018-01-31 14:44:43 -05:00
if_conversion.h Add id to name map 2018-02-14 15:53:13 -05:00
inline_exhaustive_pass.cpp Set the parent for basic blocks during inlining. 2017-12-12 13:39:08 -05:00
inline_exhaustive_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
inline_opaque_pass.cpp Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
inline_opaque_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
inline_pass.cpp Reduce instruction create and deletion during inlining. 2018-02-21 09:50:47 -05:00
inline_pass.h Convert private variables to function scope. 2017-12-19 14:21:04 -05:00
insert_extract_elim.cpp Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
insert_extract_elim.h InsertExtractElim: Split out DeadInsertElim as separate pass 2018-01-30 08:52:14 -05:00
instruction_list.cpp Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
instruction_list.h Refactor include of latest spir-v header versions 2017-12-14 11:18:20 -05:00
instruction.cpp Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
instruction.h Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
ir_builder.h Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
ir_context.cpp Opt: Check for side-effects in DCEInst() 2018-02-22 12:24:13 -05:00
ir_context.h Add id to name map 2018-02-14 15:53:13 -05:00
ir_loader.cpp Fixed typo that leaked to the binary 2017-12-03 20:42:14 -05:00
ir_loader.h Adding an unique id to Instruction generated by IRContext 2017-11-20 17:49:10 -05:00
iterator.h Fix move semantics in iterator make_range 2017-11-21 17:36:15 -05:00
licm_pass.cpp Loop invariant code motion initial implementation 2018-02-08 22:55:47 -05:00
licm_pass.h Loop invariant code motion initial implementation 2018-02-08 22:55:47 -05:00
local_access_chain_convert_pass.cpp Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
local_access_chain_convert_pass.h Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
local_redundancy_elimination.cpp Capturing value table by reference in local redundancy elim 2018-01-17 09:58:32 -05:00
local_redundancy_elimination.h Add id to name map 2018-02-14 15:53:13 -05:00
local_single_block_elim_pass.cpp Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
local_single_block_elim_pass.h Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
local_single_store_elim_pass.cpp Disambiguate between const and nonconst ForEachSuccessorLabel 2018-02-02 17:54:40 -05:00
local_single_store_elim_pass.h Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
local_ssa_elim_pass.cpp Store all enabled capabilities in the feature manger. 2017-12-21 11:14:53 -05:00
local_ssa_elim_pass.h Maintain instruction to block mapping in phi insertion 2018-01-12 10:16:53 -05:00
log.h Avoid snprintf warning in GCC 7.1 2017-05-08 15:58:24 -04:00
loop_descriptor.cpp Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
loop_descriptor.h Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
loop_unroller.cpp Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
loop_unroller.h Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
loop_utils.cpp Loop invariant code motion initial implementation 2018-02-08 22:55:47 -05:00
loop_utils.h Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
make_unique.h Relicense SPIRV-Tools under Apache 2.0 2016-09-02 10:00:29 -04:00
mem_pass.cpp Opt: Check for side-effects in DCEInst() 2018-02-22 12:24:13 -05:00
mem_pass.h Speed up Phi insertion. 2018-02-20 12:04:06 -05:00
merge_return_pass.cpp Store all enabled capabilities in the feature manger. 2017-12-21 11:14:53 -05:00
merge_return_pass.h Initial implementation of merge return pass. 2017-11-15 10:27:04 -05:00
module.cpp Adding ostream operators for IR structures 2018-01-12 11:19:58 -05:00
module.h Adding ostream operators for IR structures 2018-01-12 11:19:58 -05:00
null_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
optimizer.cpp Clean up variables before sroa 2018-02-22 21:40:58 -05:00
pass_manager.cpp Add --print-all optimizer option 2018-01-04 18:34:18 -05:00
pass_manager.h Add --print-all optimizer option 2018-01-04 18:34:18 -05:00
pass.cpp Add a new constant manager class. 2017-12-08 14:14:55 -05:00
pass.h Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
passes.h Initial support for loop unrolling. 2018-02-14 15:44:38 -05:00
private_to_local_pass.cpp Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
private_to_local_pass.h Add id to name map 2018-02-14 15:53:13 -05:00
propagator.cpp Fixes #1300. Adding checks for bad CCP transitions and unsettled values 2018-02-18 19:41:34 -05:00
propagator.h Fixes #1300. Adding checks for bad CCP transitions and unsettled values 2018-02-18 19:41:34 -05:00
redundancy_elimination.cpp Add global redundancy elimination 2017-12-07 18:35:38 -05:00
redundancy_elimination.h Add global redundancy elimination 2017-12-07 18:35:38 -05:00
reflect.h Opt: Make DecorationManager::HaveTheSameDecorations symmetric 2018-01-04 14:07:25 -05:00
remove_duplicates_pass.cpp Linker code cleanups 2018-01-05 13:28:44 -05:00
remove_duplicates_pass.h Linker code cleanups 2018-01-05 13:28:44 -05:00
replace_invalid_opc.cpp Add pass to reaplce invalid opcodes 2018-02-01 15:25:09 -05:00
replace_invalid_opc.h Add pass to reaplce invalid opcodes 2018-02-01 15:25:09 -05:00
scalar_replacement_pass.cpp SROA: Do replacement on structs with no partial references. 2018-02-08 15:20:02 -05:00
scalar_replacement_pass.h Add id to name map 2018-02-14 15:53:13 -05:00
set_spec_constant_default_value_pass.cpp Adding early exit versions of several ForEach* methods 2018-01-12 17:05:09 -05:00
set_spec_constant_default_value_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
simplification_pass.cpp Fold binary floating point operators. 2018-02-14 15:48:15 -05:00
simplification_pass.h Preserve analysies in the simplification pass 2018-02-22 16:06:30 -05:00
strength_reduction_pass.cpp Improving the usability of the type manager. The type manager hashes 2017-12-18 08:20:56 -05:00
strength_reduction_pass.h Improving the usability of the type manager. The type manager hashes 2017-12-18 08:20:56 -05:00
strip_debug_info_pass.cpp Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
strip_debug_info_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
tree_iterator.h Add loop descriptors and some required dominator tree extensions. 2018-01-08 09:31:13 -05:00
type_manager.cpp Registering a type now rebuilds it out of memory owned by the manager. 2018-02-06 10:17:56 -05:00
type_manager.h Registering a type now rebuilds it out of memory owned by the manager. 2018-02-06 10:17:56 -05:00
types.cpp Avoid vector copies in range-for loops in opt/types.cpp 2018-02-05 13:08:39 -05:00
types.h Registering a type now rebuilds it out of memory owned by the manager. 2018-02-06 10:17:56 -05:00
unify_const_pass.cpp Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
unify_const_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
value_number_table.cpp Add global redundancy elimination 2017-12-07 18:35:38 -05:00
value_number_table.h Add global redundancy elimination 2017-12-07 18:35:38 -05:00
workaround1209.cpp Create a pass to work around a driver bug related to OpUnreachable. 2018-01-18 20:31:46 -05:00
workaround1209.h Create a pass to work around a driver bug related to OpUnreachable. 2018-01-18 20:31:46 -05:00