public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ktkachov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/98477] New: aarch64: Unnecessary GPR -> FPR moves for conditional select
Date: Wed, 30 Dec 2020 09:35:35 +0000	[thread overview]
Message-ID: <bug-98477-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98477
           Summary: aarch64: Unnecessary GPR -> FPR moves for conditional
                    select
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

Code like
void
foo (int a, double *b)
{
  *b = a ? 10000.0 : 200.0;
}

generates:
foo:
        cmp     w0, 0
        mov     x2, 149533581377536
        movk    x2, 0x40c3, lsl 48
        mov     x0, 4641240890982006784
        fmov    d0, x2
        fmov    d1, x0
        fcsel   d0, d0, d1, ne
        str     d0, [x1]
        ret

We don't need to do the FCSEL on the FPR side if we're just storing it to
memory. We can just do a GPR CSEL and avoid the FMOVs.
I've seen this pattern in the disassembly of some math library routines.
Maybe we should add a =w,w,w alternative to the CSEL patterns in the backend?

             reply	other threads:[~2020-12-30  9:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30  9:35 ktkachov at gcc dot gnu.org [this message]
2020-12-30  9:40 ` [Bug target/98477] " ktkachov at gcc dot gnu.org
2020-12-30  9:47 ` pinskia at gcc dot gnu.org
2020-12-30  9:50 ` pinskia at gcc dot gnu.org
2020-12-30  9:50 ` pinskia at gcc dot gnu.org
2023-11-18  6:59 ` pinskia at gcc dot gnu.org
2024-04-24  0:02 ` pinskia at gcc dot gnu.org
2024-04-24  6:05 ` pinskia at gcc dot gnu.org
2024-04-24  6:09 ` pinskia at gcc dot gnu.org
2024-04-24  6:22 ` pinskia at gcc dot gnu.org
2024-04-24  6:28 ` pinskia at gcc dot gnu.org
2024-05-06 18:29 ` 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-98477-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).