public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare
@ 2011-03-04 14:38 rguenth at gcc dot gnu.org
  2011-03-04 16:06 ` [Bug target/47989] -mrecip causes 482.sphinx3 and 464.h264ref " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-04 14:38 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: -mrecip causes 482.sphinx3 to miscompare
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org
            Target: x86_64-*-*


We currently miscompare 482.sphinx3 with -Ofast -mrecip because for

float foo (float x, float y)
{    
  return ((int)(x/y + 0.5)) * y;
} 

we use rcpss for the division by y.  This results in a possible error
of +-1 for the integer intermediate result and an error of +-y for
the overall result.


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

* [Bug target/47989] -mrecip causes 482.sphinx3 and 464.h264ref to miscompare
  2011-03-04 14:38 [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare rguenth at gcc dot gnu.org
@ 2011-03-04 16:06 ` rguenth at gcc dot gnu.org
  2011-03-10 13:27 ` [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-04 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.03.04 16:06:42
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
            Summary|-mrecip causes 482.sphinx3  |-mrecip causes 482.sphinx3
                   |to miscompare               |and 464.h264ref to
                   |                            |miscompare
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-04 16:06:42 UTC ---
Similarly 464.h264ref miscompares because of

  fprintf(stdout, "Freq. for encoded bitstream: %1.0f\n",
          img->framerate/(float)(input->jumpd+1));

where both img->framerate and input->jumpd are input parameters
(15.0 and 1).  Here the rounding to integer happens inside fprintf.

Feeding rcps sequences into call stmts is probably never a very good idea.



Mine.  I'm going to move rcps expansion up into tree-ssa-math-opts, the
same place where we apply LCM for CSE-ing 1/x.  Probably replace the
division by a builtin.


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

* [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf to miscompare
  2011-03-04 14:38 [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare rguenth at gcc dot gnu.org
  2011-03-04 16:06 ` [Bug target/47989] -mrecip causes 482.sphinx3 and 464.h264ref " rguenth at gcc dot gnu.org
@ 2011-03-10 13:27 ` rguenth at gcc dot gnu.org
  2011-03-10 14:01 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-10 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|-mrecip causes 482.sphinx3  |-mrecip causes 482.sphinx3,
                   |and 464.h264ref to          |464.h264ref and 481.wrf to
                   |miscompare                  |miscompare

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-10 13:27:22 UTC ---
Same for 481.wrf, hope for dealing with this with taking into account context
of the division vanishes here.  The code is obfuscated with several
levels of array lookup.

In all cases the Intel compiler simply only uses rcp instructions for
vectorized loops.


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

* [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf to miscompare
  2011-03-04 14:38 [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare rguenth at gcc dot gnu.org
  2011-03-04 16:06 ` [Bug target/47989] -mrecip causes 482.sphinx3 and 464.h264ref " rguenth at gcc dot gnu.org
  2011-03-10 13:27 ` [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf " rguenth at gcc dot gnu.org
@ 2011-03-10 14:01 ` dominiq at lps dot ens.fr
  2011-10-20 15:14 ` uros at gcc dot gnu.org
  2011-10-20 15:30 ` ubizjak at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-03-10 14:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-03-10 14:01:25 UTC ---
A similar problem occurs with the polyhedron test aermod.f90 (see pr34702).

> Feeding rcps sequences into call stmts is probably never a very good idea.

Probably the same thing for tests.

> In all cases the Intel compiler simply only uses rcp instructions for
> vectorized loops.

I think this would be a good idea, however the last time I have looked at it
(some time ago!-), gcc was not as good as intel to vectorize rcp.


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

* [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf to miscompare
  2011-03-04 14:38 [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-03-10 14:01 ` dominiq at lps dot ens.fr
@ 2011-10-20 15:14 ` uros at gcc dot gnu.org
  2011-10-20 15:30 ` ubizjak at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: uros at gcc dot gnu.org @ 2011-10-20 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from uros at gcc dot gnu.org 2011-10-20 15:13:39 UTC ---
Author: uros
Date: Thu Oct 20 15:13:30 2011
New Revision: 180256

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180256
Log:
    PR target/47989
    * config/i386/i386.h (RECIP_MASK_DEFAULT): New define.
    * config/i386/i386.op (recip_mask): Initialize with RECIP_MASK_DEFAULT.
    * doc/invoke.texi (ix86 Options, -mrecip): Document that GCC
    implements vectorized single float division and vectorized sqrtf(x)
    with reciprocal sequence with additional Newton-Raphson step with
    -ffast-math.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.h
    trunk/gcc/config/i386/i386.opt
    trunk/gcc/doc/invoke.texi


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

* [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf to miscompare
  2011-03-04 14:38 [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-10-20 15:14 ` uros at gcc dot gnu.org
@ 2011-10-20 15:30 ` ubizjak at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: ubizjak at gmail dot com @ 2011-10-20 15:30 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                URL|                            |http://gcc.gnu.org/ml/gcc-p
                   |                            |atches/2011-10/msg01825.htm
                   |                            |l
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #5 from Uros Bizjak <ubizjak at gmail dot com> 2011-10-20 15:29:51 UTC ---
We now use reciprocals for vectorized operators by default, see threads at [1],
[2] and [3] for the discussion.

[1] http://gcc.gnu.org/ml/gcc-patches/2011-08/msg02550.html
[2] http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00212.html
[3] http://gcc.gnu.org/ml/gcc-patches/2011-10/msg01825.html

So, fixed.


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

end of thread, other threads:[~2011-10-20 15:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-04 14:38 [Bug target/47989] New: -mrecip causes 482.sphinx3 to miscompare rguenth at gcc dot gnu.org
2011-03-04 16:06 ` [Bug target/47989] -mrecip causes 482.sphinx3 and 464.h264ref " rguenth at gcc dot gnu.org
2011-03-10 13:27 ` [Bug target/47989] -mrecip causes 482.sphinx3, 464.h264ref and 481.wrf " rguenth at gcc dot gnu.org
2011-03-10 14:01 ` dominiq at lps dot ens.fr
2011-10-20 15:14 ` uros at gcc dot gnu.org
2011-10-20 15:30 ` 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).