public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/104485] New: x378 fmod inline code is slow
@ 2022-02-10 13:47 rguenth at gcc dot gnu.org
  2022-02-10 13:55 ` [Bug target/104485] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104485
           Summary: x378 fmod inline code is slow
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

In 526.blender_r one can see us expanding fmod as

        fld1
        fldl    (%rsi)
.L2:
        fprem
        fnstsw  %ax
        testb   $4, %ah
        jne     .L2
        fstp    %st(1)
...

which is quite a bit slower than just calling into libm.  The case in
question is actually special and can be approximated by

void foo (double * __restrict s, double *d)
{
  s[0] = fmod(d[0], 1.0f);
  s[1] = fmod(d[1], 1.0f);
}

where obtaining the fractional part of {d[0], d[1]} might even be vectorizable.

Building 526.blender_r with -fno-builtin-fmod (-mno-fancy-math-387 doesn't do
the trick here) speeds it up by 1% on Zen2.

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

* [Bug target/104485] x378 fmod inline code is slow
  2022-02-10 13:47 [Bug target/104485] New: x378 fmod inline code is slow rguenth at gcc dot gnu.org
@ 2022-02-10 13:55 ` rguenth at gcc dot gnu.org
  2022-02-10 14:11 ` [Bug target/104485] x387 " ubizjak at gmail dot com
  2022-02-10 14:18 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
To some extent fmod (x, 1.) looks equivalent to C99 modf (x, &tem) where modf
might be cheaper on the libm side.  With -ffast-math one might be
tempted to calculate fmod (x, 1.) as x - (long)x or sth similar (though the
excessive exponent of doubles make this flawed).

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

* [Bug target/104485] x387 fmod inline code is slow
  2022-02-10 13:47 [Bug target/104485] New: x378 fmod inline code is slow rguenth at gcc dot gnu.org
  2022-02-10 13:55 ` [Bug target/104485] " rguenth at gcc dot gnu.org
@ 2022-02-10 14:11 ` ubizjak at gmail dot com
  2022-02-10 14:18 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ubizjak at gmail dot com @ 2022-02-10 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |103008

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
Related to (or dup) of PR103008.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103008
[Bug 103008] poor inlined builtin_fmod on x86_64

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

* [Bug target/104485] x387 fmod inline code is slow
  2022-02-10 13:47 [Bug target/104485] New: x378 fmod inline code is slow rguenth at gcc dot gnu.org
  2022-02-10 13:55 ` [Bug target/104485] " rguenth at gcc dot gnu.org
  2022-02-10 14:11 ` [Bug target/104485] x387 " ubizjak at gmail dot com
@ 2022-02-10 14:18 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed.

*** This bug has been marked as a duplicate of bug 103008 ***

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

end of thread, other threads:[~2022-02-10 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 13:47 [Bug target/104485] New: x378 fmod inline code is slow rguenth at gcc dot gnu.org
2022-02-10 13:55 ` [Bug target/104485] " rguenth at gcc dot gnu.org
2022-02-10 14:11 ` [Bug target/104485] x387 " ubizjak at gmail dot com
2022-02-10 14:18 ` rguenth 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).