public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104754] gcc.dg/pr102892-1.c FAILs
Date: Thu, 03 Mar 2022 18:04:08 +0000	[thread overview]
Message-ID: <bug-104754-4-ltuyFdlva0@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104754-4@http.gcc.gnu.org/bugzilla/>

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-03-03
                 CC|                            |amacleod at redhat dot com

--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Confirmed on a cross to m68k-unknown-linux-gnu.

Interestingly this may actually be a regression against GCC11, at least on this
target (and possibly the others mentioned though I haven't checked).

The test verifies that there are no calls to foo().  On m68k the gate to foo()
flows through here (threadfull2 dump right before vrp2):

  <bb 3> [local count: 715863673]:
  # ivtmp.9_23 = PHI <ivtmp.9_24(11), ivtmp.9_7(9)>
  bar ();
  _2 = (void *) ivtmp.9_23;
  _1 = MEM[(long int *)_2];
  ivtmp.9_24 = ivtmp.9_23 + 4;
  if (_1 == 1)
    goto <bb 4>; [20.24%]
  else
    goto <bb 5>; [79.76%]

  <bb 4> [local count: 144890806]:
  foo ();

ivtmp.9_24 has been set previously in BB9 to:

  ivtmp.9_7 = (unsigned int) &b;

VRP2 can't seem to do anything with the above sequence, since it can't figure
out what _1 is.  I suppose it could, since there is enough information to to
get at "b" at -O3.

On x86, where the test passes, we have the following before vrp2:

 <bb 3> [local count: 477266310]:
  # c_4 = PHI <c_14(7)>
  bar ();
  _15 = (sizetype) c_4;
  _17 = MEM[(long int *)&b + _15 * 8];
  if (_17 == 1)
    goto <bb 4>; [20.24%]
  else
    goto <bb 5>; [79.76%]

  <bb 4> [local count: 96598701]:
  foo ();
  c_29 = c_4 + 1;
  goto <bb 8>; [100.00%]

which vrp2 can happily optimize to:

  <bb 6> [local count: 477266310]:
  bar ();
  _17 = 0;
  if (_17 == 1)
    goto <bb 3>; [20.24%]
  else
    goto <bb 4>; [79.76%]
...
...

 <bb 3> [local count: 96598701]:
  foo ();
  goto <bb 7>; [100.00%]

Thus leading to foo's demise by ccp4.

I haven't dug deep, but this is likely due to the pointer equivalence tracking
we use in evrp/VRP2 not being able to see that this is all funny talk for b[]:

  ivtmp.9_7 = (unsigned int) &b;
...
...
  # ivtmp.9_23 = PHI <ivtmp.9_24(11), ivtmp.9_7(9)>
  _2 = (void *) ivtmp.9_23;
  _1 = MEM[(long int *)_2];
  if (_1 == 1)

We have plans for a proper pointer range class for GCC13, though I wonder
whether we'll be able to handle the above gymnastics.

FWIW, the above transformation seems to be ivopts at play.

Whereas on x86 we go from:

 <bb 3> [local count: 715863673]:
  # c_19 = PHI <c_14(12), c_20(10)>
  bar ();
  _1 = b[c_19][0];
  if (_1 == 1)

to:

  <bb 3> [local count: 715863673]:
  # c_19 = PHI <c_14(12), c_20(10)>
  bar ();
  _23 = (sizetype) c_19;
  _1 = MEM[(long int *)&b + _23 * 8];
  if (_1 == 1)
    goto <bb 4>; [20.24%]

on m68k we transform the sequence to:

  <bb 3> [local count: 715863673]:
  # ivtmp.9_23 = PHI <ivtmp.9_24(12), ivtmp.9_7(10)>
  bar ();
  _2 = (void *) ivtmp.9_23;
  _1 = MEM[(long int *)_2];
  ivtmp.9_24 = ivtmp.9_23 + 4;
  if (_1 == 1)

Perhaps someone with more target-foo can opine.

  parent reply	other threads:[~2022-03-03 18:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 10:37 [Bug tree-optimization/104754] New: " ro at gcc dot gnu.org
2022-03-02 10:37 ` [Bug tree-optimization/104754] " ro at gcc dot gnu.org
2022-03-03 18:04 ` aldyh at gcc dot gnu.org [this message]
2022-03-03 18:12 ` aldyh at gcc dot gnu.org
2022-03-04 12:17 ` aldyh at gcc dot gnu.org
2022-05-06  8:32 ` jakub at gcc dot gnu.org
2023-05-08 12:24 ` rguenth 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-104754-4-ltuyFdlva0@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).