public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109119] New: missing loading fre with branch comparing two pointers
Date: Tue, 14 Mar 2023 04:58:30 +0000	[thread overview]
Message-ID: <bug-109119-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109119
           Summary: missing loading fre with branch comparing two pointers
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
void fun (unsigned *x, unsigned *b) {
   asm volatile(""::"r"(*x));
  unsigned *a = b;//malloc (*x);
  if (a == 0)
    return;
  if (a != x)            // (A)
    *a = *x;
  *x = *a;
}
```
GCC currently produces:
  <bb 2> [local count: 1073741824]:
  _1 = *x_6(D);
  __asm__ __volatile__("" :  : "r" _1);
  if (b_7(D) == 0B)
    goto <bb 7>; [18.09%]
  else
    goto <bb 3>; [81.91%]

  <bb 3> [local count: 879501929]:
  if (x_6(D) != b_7(D))
    goto <bb 5>; [70.00%]
  else
    goto <bb 4>; [30.00%]

  <bb 4> [local count: 263850576]:
  pretmp_10 = *b_7(D);
  goto <bb 6>; [100.00%]

  <bb 5> [local count: 615651353]:
  *b_7(D) = _1;

  <bb 6> [local count: 879501929]:
  # prephitmp_11 = PHI <pretmp_10(4), _1(5)>
  *x_6(D) = prephitmp_11;

But pretmp_10 should be the same as _1 as at that point b_7 == x_6.

Note I noticed this while looking into PR 96564.

             reply	other threads:[~2023-03-14  4:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14  4:58 pinskia at gcc dot gnu.org [this message]
2023-03-14  8:18 ` [Bug tree-optimization/109119] " rguenth at gcc dot gnu.org
2023-03-20 16:49 ` 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-109119-4@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).