SPIRV-Tools/test/opt/loop_optimizations
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
..
CMakeLists.txt Enable precompiled headers for spirv-tools(-shared) and some unit tests (#2026) 2018-11-06 09:26:23 -05:00
dependence_analysis_helpers.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
dependence_analysis.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
fusion_compatibility.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
fusion_illegal.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
fusion_legal.cpp Validate nested constructs (#3068) 2019-11-27 16:45:57 -05:00
fusion_pass.cpp Make EFFCEE required (#1943) 2018-10-04 10:00:11 -04:00
hoist_all_loop_types.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
hoist_double_nested_loops.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
hoist_from_independent_loops.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
hoist_simple_case.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
hoist_single_nested_loops.cpp In LICM don't place code between merge instruction and branch. (#2252) 2018-12-20 18:33:52 -05:00
hoist_without_preheader.cpp Document in the context what happens with id overflow. (#2159) 2018-12-06 09:07:00 -05:00
lcssa.cpp Make EFFCEE required (#1943) 2018-10-04 10:00:11 -04:00
loop_descriptions.cpp Update dominates to check for null nodes (#3271) 2020-04-02 08:19:54 -04:00
loop_fission.cpp Use structured order to unroll loops. (#3443) 2020-06-18 16:00:34 -04:00
nested_loops.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
pch_test_opt_loop.cpp Enable precompiled headers for spirv-tools(-shared) and some unit tests (#2026) 2018-11-06 09:26:23 -05:00
pch_test_opt_loop.h Enable precompiled headers for spirv-tools(-shared) and some unit tests (#2026) 2018-11-06 09:26:23 -05:00
peeling_pass.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
peeling.cpp Add base and core bindless validation instrumentation classes (#2014) 2018-11-08 13:54:54 -05:00
unroll_assumptions.cpp Support SPV_KHR_terminate_invocation (#3568) 2020-07-22 11:45:02 -04:00
unroll_simple.cpp Fix dangling phi bug from loop-unroll (#4239) 2021-04-27 16:27:09 -04:00
unswitch.cpp Don't fold specialized branches in loop unswitch (#2245) 2018-12-19 04:40:30 +00:00