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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldyh at redhat dot com,
                   |                            |amacleod at redhat dot com

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Di Zhao from comment #0)
> GCC fail to remove dead codes for following cases:
> 
> #include <stdio.h>
> 
> void f (unsigned int a, unsigned int b, unsigned int c)
> // if a,b,c are signed, VRP can remove dead code
> {
>   if (a == b)
>     {
>       printf ("a");
>       if (c < a)
>       {
>         printf ("b");
>         if (c >= b)
>           printf ("Unreachable!");
>       }
>     }
> }
> 
I believe this commit fixes the first case, EVRP now eliminates the unreachable
print.


commit ce0b409f562cd09c67cc2dce74143a0f0647cde5 (origin/master, origin/HEAD)
Author: Andrew MacLeod <amacl...@redhat.com>
Date:   Thu Jun 24 11:13:47 2021 -0400

    Fix relation query of equivalences.

the second one requires some form of predication, or the desire to thread thru
the top of the block.. It touches on some stuff Aldy is looking at (which isn't
finished yet) .


<bb 2> :
  if (a_7(D) != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 9>; [INV]

  <bb 3> :
  goto <bb 9>; [INV]

  <bb 9> :
  # c_16 = PHI <x_10(D)(3), y_5(D)(2)>

  <bb 10> :
  # b_1 = PHI <b_8(D)(9), b_14(8)>
  if (b_1 <= 999)
    goto <bb 4>; [INV]
  else
    goto <bb 11>; [INV]

  <bb 4> :
  if (a_7(D) != 0)
    goto <bb 5>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 5> :
  if (x_10(D) < c_16)
    goto <bb 6>; [INV]
  else
    goto <bb 8>; [INV]

 I dont know what rules there are, but the path 2->3->9->10->4  would result in
bb4 becoming "goto bb5", and then BB5 could fold to "goto bb8" as c_16 == x_10
on that path in BB9.

Reply via email to