SPIRV-Tools/test/opt
Jaebaek Seo 089d716d25
Fix dangling phi bug from loop-unroll (#4239)
Fix dangling phi bug from loop-unroll

When unrolling the following loop:
```
%const0 = OpConstant ...
%const1 = OpConstant ...
...
%LoopHeader = OpLabel
%phi0 = OpPhi %float %const0 %PreHeader %phi1 %Latch
%phi1 = OpPhi %float %const1 %PreHeader %x    %Latch
...
%LoopBody = OpLabel
%x = OpFSub %float %phi1 %phi0
...
```

the loop-unroll pass sets the value of `%phi0` as `%phi1` for the second
copy of the loop body. For example, the second copy of
`%x = OpFSub %float %phi1 %phi0` will be
`%y = OpFSub %float %x %phi1`.

Since all phi instructions for inductions will are removed after the
loop unrolling, `%phi1` will be a dead dangling phi.

It happens only for the phi values of the first loop iteration. Replacing those
dangling phis with their initial values fixes this issue.

For example, the second copy of `%x = OpFSub %float %phi1 %phi0` should be
`%y = OpFSub %float %x %const1` because the value of `%phi1` from the
first loop iteration is `%const1`.
2021-04-27 16:27:09 -04:00
..
dominator_tree spirv-opt: Add support for OpLabel to dominator analysis (#3516) 2020-07-15 12:59:35 +01:00
loop_optimizations Fix dangling phi bug from loop-unroll (#4239) 2021-04-27 16:27:09 -04:00
aggressive_dead_code_elim_test.cpp Require an OpSelectionMerge before an OpSwitch (#4154) 2021-03-02 15:40:56 -05:00
amd_ext_to_khr.cpp Handle TimeAMD in AmdExtensionToKhrPass. (#3168) 2020-02-03 12:13:32 -05:00
assembly_builder_test.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
assembly_builder.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
block_merge_test.cpp Require an OpSelectionMerge before an OpSwitch (#4154) 2021-03-02 15:40:56 -05:00
ccp_test.cpp Simplify logic to decide whether CCP modified the IR (#3997) 2020-10-28 10:18:34 -04:00
cfg_cleanup_test.cpp Add validation for execution modes 2018-10-02 10:22:23 -04:00
cfg_test.cpp Change implementation of post order CFG traversal (#2543) 2019-04-29 17:09:20 -04:00
CMakeLists.txt Add interpolate legalization pass (#4220) 2021-03-31 14:26:36 -04:00
code_sink_test.cpp Handle instructions not in blocks in code sinking. (#2308) 2019-01-21 12:09:56 -05:00
combine_access_chains_test.cpp Make EFFCEE required (#1943) 2018-10-04 10:00:11 -04:00
compact_ids_test.cpp Handle DebugScope in compact-ids pass (#3724) 2020-08-26 10:15:36 -04:00
constant_manager_test.cpp Handle id overflow in the constant manager. (#2844) 2019-09-09 15:12:26 -04:00
constants_test.cpp Add pass to inject code for robust-buffer-access semantics (#2771) 2019-07-30 19:52:46 -04:00
convert_relaxed_to_half_test.cpp Mark module as modified if convert-to-half removes decorations. (#4127) 2021-01-28 15:53:34 -05:00
copy_prop_array_test.cpp Debug info preservation in copy-prop-array pass (#3444) 2020-07-06 13:48:12 -04:00
dead_branch_elim_test.cpp Require an OpSelectionMerge before an OpSwitch (#4154) 2021-03-02 15:40:56 -05:00
dead_insert_elim_test.cpp Preserve debug info in dead-insert-elim pass (#3652) 2020-08-12 10:19:37 -04:00
dead_variable_elim_test.cpp Validate variable initializer type (#2668) 2019-06-15 00:34:18 -04:00
debug_info_manager_test.cpp Set correct scope and line info for DebugValue (#4125) 2021-01-28 12:57:35 -05:00
decoration_manager_test.cpp Add descriptor array scalar replacement (#2742) 2019-08-08 10:53:19 -04:00
def_use_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
desc_sroa_test.cpp Fix binding number calculation in desc sroa (#4095) 2021-01-06 13:59:04 -05:00
eliminate_dead_const_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
eliminate_dead_functions_test.cpp Improve non-semantic instruction handling in the optimizer (#3693) 2020-08-13 14:54:14 -04:00
eliminate_dead_member_test.cpp Handle 8-bit index in elim dead member (#4043) 2020-12-01 14:48:25 -05:00
feature_manager_test.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
fix_storage_class_test.cpp spirv-opt: Don't call GenerateCopy for mismatched image types (#4126) 2021-02-19 10:59:14 -05:00
flatten_decoration_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
fold_spec_const_op_composite_test.cpp Support constant-folding UConvert and SConvert (#2960) 2019-10-16 16:29:55 -04:00
fold_test.cpp Support folding OpBitcast with numeric constants (#4247) 2021-04-27 14:24:46 -04:00
freeze_spec_const_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
function_test.cpp spirv-opt: Implement opt::Function::HasEarlyReturn function (#3711) 2020-08-18 09:31:24 -04:00
function_utils.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
graphics_robust_access_test.cpp GraphicsRobustAccessPass: Set module_status_.modified (#4167) 2021-04-26 17:14:35 +01:00
if_conversion_test.cpp Debug info preservation in if-conversion pass (#3861) 2020-10-01 09:20:27 -04:00
inline_opaque_test.cpp Reject SPIR-V that applies void to OpUndef, OpCopyObject, OpPhi (#4036) 2020-11-27 16:31:04 +00:00
inline_test.cpp Take new (raytracing) termination instructions into account. (#4050) 2020-12-07 10:26:05 -05:00
insert_extract_elim_test.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
inst_bindless_check_test.cpp Generate differentiated error codes for buffer oob checking (#4144) 2021-02-11 17:24:04 -05:00
inst_buff_addr_check_test.cpp Make Instrumentation format version 2 the default (Step 1) (#3096) 2019-12-16 14:18:47 -05:00
inst_debug_printf_test.cpp Instrument: Debug Printf support (#3215) 2020-03-12 09:19:52 -04:00
instruction_list_test.cpp Fix -Wextra-semi-stmt -Wsuggest-destructor-override -Wdeprecated-copy-dtor (#4164) 2021-03-09 13:16:43 +00:00
instruction_test.cpp Generalize IsReadOnlyVariable() to apply to pointers (#3325) 2020-04-30 22:47:20 +01:00
interp_fixup_test.cpp Add interpolate legalization pass (#4220) 2021-03-31 14:26:36 -04:00
ir_builder.cpp Add support for KHR_ray_{query,tracing} extensions (#3235) 2020-03-17 15:30:19 -04:00
ir_context_test.cpp Add DebugValue for DebugDecl invisible to value assignment (#3973) 2020-10-27 15:10:08 -04:00
ir_loader_test.cpp BuildModule: optionally avoid adding new OpLine instructions (#4033) 2020-11-25 14:54:32 -05:00
iterator_test.cpp Move make_unique to source/util. (#1836) 2018-08-14 12:44:54 -04:00
line_debug_info_test.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
local_access_chain_convert_test.cpp Propagate OpLine to all applied instructions in spirv-opt (#3951) 2020-10-29 13:06:30 -04:00
local_redundancy_elimination_test.cpp Fix identification of Vulkan images and buffers (#3253) 2020-03-25 17:38:24 -04:00
local_single_block_elim.cpp Upgrade elim-local-single-block for OpenCL.DebugInfo.100 (#3451) 2020-07-09 17:21:39 -04:00
local_single_store_elim_test.cpp Set correct scope and line info for DebugValue (#4125) 2021-01-28 12:57:35 -05:00
local_ssa_elim_test.cpp Set correct scope and line info for DebugValue (#4125) 2021-01-28 12:57:35 -05:00
module_test.cpp Improve non-semantic instruction handling in the optimizer (#3693) 2020-08-13 14:54:14 -04:00
module_utils.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
optimizer_test.cpp Remove WebGPU support (#4108) 2021-01-14 16:45:18 -05:00
pass_fixture.h CCP should mark IR changed if it created new constants. (#3732) 2020-08-20 16:48:11 -04:00
pass_manager_test.cpp Fix memory leak in unrolling. (#2301) 2019-01-17 16:02:43 -05:00
pass_merge_return_test.cpp Update some language usage. (#3611) 2020-07-29 13:50:58 -04:00
pass_remove_duplicates_test.cpp Fixup readabilty/inheritance warnings (#1805) 2018-08-07 09:10:03 -04:00
pass_utils.cpp Check for unreachable blocks in merge-return. (#1966) 2018-10-10 15:18:15 -04:00
pass_utils.h Fix gtest.h include in test/opt/pass_utils.h 2018-10-12 10:22:25 -04:00
pch_test_opt.cpp Rename PCH macro to spvtools_pch to avoid conflicts with other projects. Also add pch to test/opt. (#2034) 2018-11-07 09:15:04 -05:00
pch_test_opt.h Rename PCH macro to spvtools_pch to avoid conflicts with other projects. Also add pch to test/opt. (#2034) 2018-11-07 09:15:04 -05:00
private_to_local_test.cpp Preserve OpenCL.DebugInfo.100 through private-to-local pass (#3571) 2020-07-27 09:27:47 -04:00
propagator_test.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
reduce_load_size_test.cpp Preserve OpenCL.100.DebugInfo in reduce-load-size pass (#3492) 2020-07-08 16:34:00 -04:00
redundancy_elimination_test.cpp Propagate OpLine to all applied instructions in spirv-opt (#3951) 2020-10-29 13:06:30 -04:00
register_liveness.cpp Handle unreachable block when computing register pressure (#3070) 2019-11-27 09:45:17 -05:00
relax_float_ops_test.cpp Add --relax-float-ops and --convert-relaxed-to-half (#2808) 2019-09-03 13:22:13 -04:00
replace_invalid_opc_test.cpp Check for unreachable blocks in merge-return. (#1966) 2018-10-10 15:18:15 -04:00
scalar_analysis.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
scalar_replacement_test.cpp Accept OpImageTexelPointer user in scalar-replacement (#4187) 2021-03-16 16:40:51 -04:00
set_spec_const_default_value_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
simplification_test.cpp Add two new simplifications. (#2984) 2019-10-28 08:19:38 -07:00
strength_reduction_test.cpp Make EFFCEE required (#1943) 2018-10-04 10:00:11 -04:00
strip_debug_info_test.cpp Add support for SPV_KHR_non_semantic_info (#3110) 2019-12-18 18:10:29 -05:00
strip_reflect_info_test.cpp Improve non-semantic instruction handling in the optimizer (#3693) 2020-08-13 14:54:14 -04:00
struct_cfg_analysis_test.cpp spirv-opt: Add function to compute nesting depth of a block (#3771) 2020-09-08 12:01:56 +01:00
type_manager_test.cpp Add support for KHR_ray_{query,tracing} extensions (#3235) 2020-03-17 15:30:19 -04:00
types_test.cpp Remove useless semi-colons (#2789) 2019-08-12 08:52:39 -04:00
unify_const_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
upgrade_memory_model_test.cpp Fix operand access of composite in upgrade memory model (#3021) 2019-11-12 13:41:38 -05:00
utils_test.cpp Remove use of deprecated googletest macro (#2286) 2019-01-29 18:56:52 -05:00
value_table_test.cpp Debug info preservation in redundancy-elimination pass (#3839) 2020-10-01 09:22:16 -04:00
vector_dce_test.cpp Preserve debug info in vector DCE pass (#3497) 2020-07-10 10:19:34 -04:00
workaround1209_test.cpp Make EFFCEE required (#1943) 2018-10-04 10:00:11 -04:00
wrap_opkill_test.cpp Propagate OpLine to all applied instructions in spirv-opt (#3951) 2020-10-29 13:06:30 -04:00