public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/55760] scalar code non using rsqrtss and rcpss
Date: Thu, 20 Dec 2012 16:07:00 -0000	[thread overview]
Message-ID: <bug-55760-4-pPNiDVeX0x@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55760-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55760

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-12-20 16:07:11 UTC ---
> is there any reason why rsqrtss and rcpss are not used for scalar code while
> rsqrtps and rcpps are used for loops?

Yep! I don't have the patience to dig the bugzilla archive right now, but the
main reason is related to a loss of accuracy (especially 1/2.0 != 0.5) leading
to problems in some codes (see gas_dyn.f90 in the polyhedron tests). You can
pass options to force the use of rsqrtss and rcpss for scalars:

-mrecip
This option enables use of RCPSS and RSQRTSS instructions (and their vectorized
variants RCPPS and RSQRTPS) with an additional Newton-Raphson step to increase
precision instead of DIVSS and SQRTSS (and their vectorized variants) for
single-precision floating-point arguments. These instructions are generated
only when -funsafe-math-optimizations is enabled together with
-finite-math-only and -fno-trapping-math. Note that while the throughput of the
sequence is higher than the throughput of the non-reciprocal instruction, the
precision of the sequence can be decreased by up to 2 ulp (i.e. the inverse of
1.0 equals 0.99999994).
Note that GCC implements 1.0f/sqrtf(x) in terms of RSQRTSS (or RSQRTPS) already
with -ffast-math (or the above option combination), and doesn't need -mrecip.

Also note that GCC emits the above sequence with additional Newton-Raphson step
for vectorized single-float division and vectorized sqrtf(x) already with
-ffast-math (or the above option combination), and doesn't need -mrecip. 

-mrecip=opt
This option controls which reciprocal estimate instructions may be used. opt is
a comma-separated list of options, which may be preceded by a `!' to invert the
option:
`all'
Enable all estimate instructions. 
`default'
Enable the default instructions, equivalent to -mrecip. 
`none'
Disable all estimate instructions, equivalent to -mno-recip. 
`div'
Enable the approximation for scalar division. 
`vec-div'
Enable the approximation for vectorized division. 
`sqrt'
Enable the approximation for scalar square root. 
`vec-sqrt'
Enable the approximation for vectorized square root.
So, for example, -mrecip=all,!sqrt enables all of the reciprocal
approximations, except for square root.


  parent reply	other threads:[~2012-12-20 16:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-20 15:49 [Bug tree-optimization/55760] New: " vincenzo.innocente at cern dot ch
2012-12-20 15:52 ` [Bug tree-optimization/55760] " rguenth at gcc dot gnu.org
2012-12-20 15:55 ` vincenzo.innocente at cern dot ch
2012-12-20 15:59 ` rguenth at gcc dot gnu.org
2012-12-20 16:07 ` dominiq at lps dot ens.fr [this message]
2013-01-08 15:29 ` vincenzo.innocente at cern dot ch
2013-01-08 23:55 ` glisse at gcc dot gnu.org
2021-08-07 22:59 ` 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-55760-4-pPNiDVeX0x@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).