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 rtl-optimization/101044] New: -ABS(A) produces two neg instructions
Date: Sun, 13 Jun 2021 02:37:07 +0000	[thread overview]
Message-ID: <bug-101044-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 101044
           Summary: -ABS(A) produces two neg instructions
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-linux-gnu

Take:
int f4(int A)
{
  return A <= 0? A : -A;
}
int f5(int A)
{
return A < 0?  A : -A;
}
int f2(int A)
{
  A = A < 0 ? -A : A;
  return -A;
}
---- CUT ---
On x86_64 we get two neg for each of these functions now, we used to get none
sometime ago.
Right now we get for each of them:
        movl    %edi, %eax
        negl    %eax
        cmovs   %edi, %eax
        negl    %eax
----- CUT ---
Note aarch64 seems to be fine:
        cmp     w0, 0
        csneg   w0, w0, w0, lt

             reply	other threads:[~2021-06-13  2:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13  2:37 pinskia at gcc dot gnu.org [this message]
2021-06-13 12:00 ` [Bug rtl-optimization/101044] " ubizjak at gmail dot com
2021-06-29  9:38 ` ubizjak at gmail dot com
2021-06-29  9:51 ` ubizjak at gmail dot com
2021-07-01  9:21 ` [Bug target/101044] " cvs-commit at gcc dot gnu.org
2021-07-01  9:24 ` ubizjak at gmail 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-101044-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).