https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123417

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> Disambiguating loop 2 with multiple latches
> Merged latch edges of loop 2
> 
> this looks odd.
> 
> But
> 
> When bb 6 is created we get this phi:
>   # BS_INC_1_86 = PHI <_87(22), _87(12)>
> 
> I wonder why this degenerate PHI was created in the first place.

The way make_forwarder_block works is by creating a forwarder block and then
move the edges to that new block. And create the phis unconditionally and then
populate them from the edge.  There is no going back.


So we start out with:
  # BS_INC_1_45 = PHI <_87(18), 0(4), _87(12)>


And then the newforwarder gets:
# BS_INC_1_86 = PHI <_87(22), _87(12)>

While the old bb gets:
  # BS_INC_1_45 = PHI <BS_INC_1_86 (N), 0(4)>



This is also the reason why make_forwarders_with_degenerate_phis rolls its own:
```
                  /* Instead of using make_forwarder_block we are
                     rolling our own variant knowing that the forwarder
                     does not need PHI nodes apart from eventually
                     a virtual one.  */
```


I am thinking there might be 2 different patches come out from this. One is to
improve/fix make_forwarder_block and one for the maybe_remove_forwarder_block
for loop latches.

Reply via email to