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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Drea Pinski from comment #1)
> Take:
> ```
> void foo (void);
> 
> static void __attribute__((noinline))
> spin (int n)
> {
>   while (n)
>     ;
> }
> 
> int t ;
> double t1;
> 
> void
> f (int *p, int k)
> {
>   t = 1;
>   if (*p == k)
>     ;
>   else
>     t = 2;
> #ifndef OK
>   spin (k);
> #endif
>   if (*p != k)
>     foo ();
> }
> ```
> 
> PRE is able to handle it when OK is defined.
> 
> I think DOM skips over calls that don't have VDEF while VN only does that
> for functions which are marked as const or pure (if I am reading the code
> correctly).

spin () might not return, so PRE drops all possibly trapping expressions
from getting upward during dataflow (and if course it does not track
"trapping" in any fancy way).  VN itself doesn't care, the issue there
is the merge PHI for the t = 2 VDEF.  So it would need PRE, but see above,
even looping const/pure functions can not "exit".

DOMs memory walking handling is nice in the way it works as it knows before
even starting that there's a dominating syntactic equivalent expression
(also solving the trapping issue).

Reply via email to