public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/101044] New: -ABS(A) produces two neg instructions
@ 2021-06-13  2:37 pinskia at gcc dot gnu.org
  2021-06-13 12:00 ` [Bug rtl-optimization/101044] " ubizjak at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-13  2:37 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-01  9:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13  2:37 [Bug rtl-optimization/101044] New: -ABS(A) produces two neg instructions pinskia at gcc dot gnu.org
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

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).