public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109829] New: Optimizing __builtin_signbit(x) ? -x : x or abs for FP
@ 2023-05-12 13:23 antoshkka at gmail dot com
  2023-05-12 18:16 ` [Bug tree-optimization/109829] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: antoshkka at gmail dot com @ 2023-05-12 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109829
           Summary: Optimizing __builtin_signbit(x) ? -x : x or abs for FP
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

Consider the following 2 functions:

__float128 abs1(__float128 x) { return __builtin_fabsf128(x); }
__float128 abs2(__float128 x) { return __builtin_signbit(x) ? -x : x; }

They should provide the same results, however the codegen is different:

abs1(__float128):
        pand    xmm0, XMMWORD PTR .LC0[rip]
        ret
abs2(__float128):
        movmskps        eax, xmm0
        test    al, 8
        je      .L4
        pxor    xmm0, XMMWORD PTR .LC1[rip]
.L4:
        ret


Looks like match.pd miss the __builtin_signbit(x) ? -x : x ->
__builtin_fabs*(x) pattern.

Playground: https://godbolt.org/z/bsxeozGqv

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

end of thread, other threads:[~2023-05-14 23:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 13:23 [Bug tree-optimization/109829] New: Optimizing __builtin_signbit(x) ? -x : x or abs for FP antoshkka at gmail dot com
2023-05-12 18:16 ` [Bug tree-optimization/109829] " pinskia at gcc dot gnu.org
2023-05-12 19:25 ` pinskia at gcc dot gnu.org
2023-05-12 19:34 ` pinskia at gcc dot gnu.org
2023-05-12 20:02 ` jakub at gcc dot gnu.org
2023-05-12 20:03 ` jakub at gcc dot gnu.org
2023-05-12 20:18 ` pinskia at gcc dot gnu.org
2023-05-13 15:53 ` pinskia at gcc dot gnu.org
2023-05-13 22:29 ` pinskia at gcc dot gnu.org
2023-05-14  4:04 ` pinskia at gcc dot gnu.org
2023-05-14 23:08 ` cvs-commit at gcc dot gnu.org
2023-05-14 23:09 ` pinskia at gcc dot gnu.org

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