public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94566] conversion between std::strong_ordering and int
Date: Tue, 14 Apr 2020 06:57:51 +0000	[thread overview]
Message-ID: <bug-94566-4-oFqpLA0eej@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94566-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
So for conv2 the most immediate issue is that we're failing to sink and common
the assignment to D.8516._M_value (I had patches for this).

conv2 (int i)
{
  int i_2(D) = i;
  struct strong_ordering D.8516;

  <bb 2> [local count: 1073741824]:
  if (i_2(D) == 0)
    goto <bb 5>; [33.33%]
  else
    goto <bb 3>; [66.67%]

  <bb 3> [local count: 1073741824]:
  if (i_2(D) == 1)
    goto <bb 6>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 4> [local count: 357878150]:
  D.8516._M_value = -1;
  goto <bb 7>; [100.00%]

  <bb 5> [local count: 357878150]:
  D.8516._M_value = 0;
  goto <bb 7>; [100.00%]

  <bb 6> [local count: 357878150]:
  D.8516._M_value = 1;

  <bb 7> [local count: 1073634451]:
  return D.8516;

for conv1 this is a missed phi-opt, at phiopt2 time:

conv1 (struct strong_ordering s)
{
  int SR.4;
  int _1;

  <bb 2> [local count: 1073741824]:
  SR.4_4 = s._M_value;
  if (SR.4_4 == -1)
    goto <bb 6>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870913]:
  if (SR.4_4 == 0)
    goto <bb 6>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 4> [local count: 268435456]:
  if (SR.4_4 == 1)
    goto <bb 6>; [100.00%]
  else
    goto <bb 5>; [0.00%]

  <bb 5> [count: 0]:
  __builtin_unreachable ();

  <bb 6> [local count: 1073741824]:
  # RANGE [-1, 1]
  # _1 = PHI <-1(2), 0(3), 1(4)>
  return _1;

it's a bit of a convoluted case of course but the only chance to pattern
match this ...

  parent reply	other threads:[~2020-04-14  6:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-11 22:04 [Bug tree-optimization/94566] New: " glisse at gcc dot gnu.org
2020-04-13 20:24 ` [Bug tree-optimization/94566] " redi at gcc dot gnu.org
2020-04-14  6:57 ` rguenth at gcc dot gnu.org [this message]
2020-04-15 10:23 ` rguenth at gcc dot gnu.org
2020-04-15 10:32 ` glisse at gcc dot gnu.org
2020-05-15  6:57 ` rguenth at gcc dot gnu.org
2021-06-15  1:15 ` pinskia at gcc dot gnu.org
2021-08-03  9:37 ` marxin at gcc dot gnu.org
2021-08-03  9:39 ` marxin at gcc dot gnu.org
2021-08-03  9:41 ` marxin at gcc dot gnu.org
2022-03-14 16:53 ` oschonrock at gmail dot com
2022-03-14 17:10 ` jakub at gcc dot gnu.org
2022-03-14 17:15 ` oschonrock at gmail dot com
2022-03-14 17:25 ` jakub at gcc dot gnu.org
2023-06-07 17:31 ` pinskia at gcc dot gnu.org
2023-06-07 20:27 ` amacleod at redhat dot com

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-94566-4-oFqpLA0eej@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).