public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101186] predictable comparison of integer variables not folded
Date: Thu, 24 Jun 2021 18:30:42 +0000	[thread overview]
Message-ID: <bug-101186-4-S6fbfrOKCI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101186-4@http.gcc.gnu.org/bugzilla/>

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 <amacleod@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.

  parent reply	other threads:[~2021-06-24 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24  4:25 [Bug tree-optimization/101186] New: " dizhao at os dot amperecomputing.com
2021-06-24  4:33 ` [Bug tree-optimization/101186] " pinskia at gcc dot gnu.org
2021-06-24  6:49 ` rguenth at gcc dot gnu.org
2021-06-24  6:50 ` rguenth at gcc dot gnu.org
2021-06-24  9:08 ` dizhao at os dot amperecomputing.com
2021-06-24 18:30 ` amacleod at redhat dot com [this message]
2021-06-27 15:30 ` aldyh at gcc dot gnu.org
2021-06-27 15:33 ` aldyh at gcc dot gnu.org
2021-06-28 19:20 ` law at gcc dot gnu.org
2021-07-19  6:35 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101186-4-S6fbfrOKCI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).