[Bug tree-optimization/103721] [12 regression] wrong code generated for loop with conditional since r12-4790-g4b3a325f07acebf4

amacleod at redhat dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 20 14:12:03 GMT 2022


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

--- Comment #14 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Aldy Hernandez from comment #11)
> <bb 3> [local count: 1063004409]:
>  # j_17 = PHI <j_2(9), 0(2)>
>  # q_18 = PHI <prephitmp_16(9), &a(2)>
>

>   <bb 5> [local count: 1063004409]:
>   # j_2 = PHI <j_8(4), 0(3)>
>   # prephitmp_16 = PHI <_14(4), &a(3)>
>   if (prephitmp_16 == q_18)
>     goto <bb 6>; [0.00%]
>   else
>     goto <bb 7>; [100.00%]
> 
>   <bb 9> [local count: 1052374367]:
>   goto <bb 3>; [100.00%]
> 
> Even if we reset relations and clear the root oracle at the backedge (9->3),
> we still get the _16 == _18 in BB3, followed by the DEF of _16 in BB5.

Well, you cant add that relation either..    although you have cleared the
existing relations when you traverse the back edge, you are then immediately
adding another one FROM the backedge (9->3) which is a value from the previous
iteration... so it cant be used. 

You need to also stipulate that if you are adding an equivalence from a PHI
like that, it is not a back edge you are adding from.


And I think it is probably safe to "reset" the root oracle to search for
relations from top of the loop, assuming it dominates the latch it came from. 
Any new relations are going to now be dominated by this block.


More information about the Gcc-bugs mailing list