SPIRV-Tools/source/opt
Diego Novillo 735d8a579e SSA rewrite pass.
This pass replaces the load/store elimination passes.  It implements the
SSA re-writing algorithm proposed in

     Simple and Efficient Construction of Static Single Assignment Form.
     Braun M., Buchwald S., Hack S., Leißa R., Mallon C., Zwinkau A. (2013)
     In: Jhala R., De Bosschere K. (eds)
     Compiler Construction. CC 2013.
     Lecture Notes in Computer Science, vol 7791.
     Springer, Berlin, Heidelberg

     https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6

In contrast to common eager algorithms based on dominance and dominance
frontier information, this algorithm works backwards from load operations.

When a target variable is loaded, it queries the variable's reaching
definition.  If the reaching definition is unknown at the current location,
it searches backwards in the CFG, inserting Phi instructions at join points
in the CFG along the way until it finds the desired store instruction.

The algorithm avoids repeated lookups using memoization.

For reducible CFGs, which are a superset of the structured CFGs in SPIRV,
this algorithm is proven to produce minimal SSA.  That is, it inserts the
minimal number of Phi instructions required to ensure the SSA property, but
some Phi instructions may be dead
(https://en.wikipedia.org/wiki/Static_single_assignment_form).
2018-03-20 20:56:55 -04:00
..
aggressive_dead_code_elim_pass.cpp Add recent Google extensions to optimizer whitelists 2018-03-15 11:16:20 -04:00
aggressive_dead_code_elim_pass.h Fixes #1404. Don't DCE workgroup size 2018-03-13 19:38:31 -04:00
basic_block.cpp SSA rewrite pass. 2018-03-20 20:56:55 -04:00
basic_block.h SSA rewrite pass. 2018-03-20 20:56:55 -04:00
block_merge_pass.cpp Fixes #1402. Don't merge non-branch terminators into loop header. 2018-03-13 22:16:17 -04:00
block_merge_pass.h Remove extension whitelist from some transforms 2018-03-08 12:25:49 -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 #1361. Mark all non-constant global values as varying in CCP 2018-03-01 15:24:41 -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 Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
cfg.h Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
CMakeLists.txt SSA rewrite pass. 2018-03-20 20:56:55 -04:00
common_uniform_elim_pass.cpp Add recent Google extensions to optimizer whitelists 2018-03-15 11:16:20 -04: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 Opt: Add constant folding for FToI and IToF 2018-02-28 23:08:52 -05:00
const_folding_rules.h Consistently include latest spirv.h header file. 2018-02-27 18:47:29 -05:00
constants.cpp Merge arithmetic with non-trivial constant operands 2018-02-27 13:02:13 -05:00
constants.h Fixes #1357. Support null constants better in folding 2018-02-28 23:12:27 -05:00
dead_branch_elim_pass.cpp Remove extension whitelist from some transforms 2018-03-08 12:25:49 -05:00
dead_branch_elim_pass.h Remove extension whitelist from some transforms 2018-03-08 12:25:49 -05:00
dead_insert_elim_pass.cpp NFC: Speed up dead insert phi traversal on Windows. 2018-03-14 17:45:47 -04:00
dead_insert_elim_pass.h NFC: Speed up dead insert phi traversal on Windows. 2018-03-14 17:45:47 -04: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 Teach DecorationManager about OpDecorateStringGOOGLE 2018-03-13 22:18:33 -04:00
decoration_manager.h Reimplement the DecorationManager 2018-03-12 09:56:14 -04:00
def_use_manager.cpp Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04: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 Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
dominator_tree.h Add loop unswitch pass. 2018-02-27 08:52:46 -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 Merge arithmetic with non-trivial constant operands 2018-02-27 13:02:13 -05:00
fold.h Get CCP to use the constant floating point rules. 2018-02-16 13:49:47 -05:00
folding_rules.cpp Fix InsertFeedingExtract rule when extract remains. 2018-03-12 22:06:23 -04: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 SSA rewrite pass. 2018-03-20 20:56:55 -04:00
function.h SSA rewrite pass. 2018-03-20 20:56:55 -04:00
if_conversion.cpp Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04: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 Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
inline_pass.h Reimplement the DecorationManager 2018-03-12 09:56:14 -04:00
insert_extract_elim.cpp Remove extension whitelist from some transforms 2018-03-08 12:25:49 -05:00
insert_extract_elim.h Remove extension whitelist from some transforms 2018-03-08 12:25:49 -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 Reimplement the DecorationManager 2018-03-12 09:56:14 -04:00
ir_builder.h Add loop peeling utility 2018-03-20 10:21:10 -04:00
ir_context.cpp Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
ir_context.h Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04: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 Add loop unswitch pass. 2018-02-27 08:52:46 -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 Add recent Google extensions to optimizer whitelists 2018-03-15 11:16:20 -04: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 Add recent Google extensions to optimizer whitelists 2018-03-15 11:16:20 -04: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 Add recent Google extensions to optimizer whitelists 2018-03-15 11:16:20 -04:00
local_single_store_elim_pass.h Remove uses DCEInst and call ADCE 2018-02-27 21:06:08 -05:00
local_ssa_elim_pass.cpp SSA rewrite pass. 2018-03-20 20:56:55 -04:00
local_ssa_elim_pass.h Remove uses DCEInst and call ADCE 2018-02-27 21:06:08 -05:00
log.h Avoid snprintf warning in GCC 7.1 2017-05-08 15:58:24 -04:00
loop_descriptor.cpp Add loop peeling utility 2018-03-20 10:21:10 -04:00
loop_descriptor.h Add loop unswitch pass. 2018-02-27 08:52:46 -05:00
loop_peeling.cpp Add loop peeling utility 2018-03-20 10:21:10 -04:00
loop_peeling.h Add loop peeling utility 2018-03-20 10:21:10 -04:00
loop_unroller.cpp Unroller support for multiple induction variables 2018-02-27 11:50:08 +00:00
loop_unroller.h Unroller support for multiple induction variables 2018-02-27 11:50:08 +00:00
loop_unswitch_pass.cpp Add loop peeling utility 2018-03-20 10:21:10 -04:00
loop_unswitch_pass.h Add loop unswitch pass. 2018-02-27 08:52:46 -05:00
loop_utils.cpp Add loop peeling utility 2018-03-20 10:21:10 -04:00
loop_utils.h Add loop peeling utility 2018-03-20 10:21:10 -04:00
make_unique.h Relicense SPIRV-Tools under Apache 2.0 2016-09-02 10:00:29 -04:00
mem_pass.cpp SSA rewrite pass. 2018-03-20 20:56:55 -04:00
mem_pass.h SSA rewrite pass. 2018-03-20 20:56:55 -04:00
merge_return_pass.cpp Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
merge_return_pass.h Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04: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 SSA rewrite pass. 2018-03-20 20:56:55 -04: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 SSA rewrite pass. 2018-03-20 20:56:55 -04:00
passes.h SSA rewrite pass. 2018-03-20 20:56:55 -04: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 Support SPV_GOOGLE_decorate_string and SPV_GOOGLE_hlsl_functionality1 2018-03-05 13:34:13 -05:00
remove_duplicates_pass.cpp Avoid generating duplicate names when merging types 2018-03-05 12:02:50 -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
ssa_rewrite_pass.cpp SSA rewrite pass. 2018-03-20 20:56:55 -04:00
ssa_rewrite_pass.h SSA rewrite pass. 2018-03-20 20:56:55 -04: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
strip_reflect_info_pass.cpp Add --strip-reflect pass 2018-03-15 21:20:42 -04:00
strip_reflect_info_pass.h Add --strip-reflect pass 2018-03-15 21:20:42 -04:00
tree_iterator.h Add loop descriptors and some required dominator tree extensions. 2018-01-08 09:31:13 -05:00
type_manager.cpp Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
type_manager.h Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
types.cpp Fixes #1407. Removing assertion against void pointer 2018-03-13 19:45:20 -04: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