public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math
@ 2013-03-13  2:55 udifuchs at gmail dot com
  2013-03-13  2:56 ` [Bug c/56608] " udifuchs at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: udifuchs at gmail dot com @ 2013-03-13  2:55 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56608
           Summary: built-in floor function returns false results when
                    build with -ffast-math
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: udifuchs@gmail.com


In some cases floor() seems to return 0 value even if its argument is larger
than 1. This happens when compiling with '-O3 -ffast-math'.

Attached is the smallest code I found, which reproduces the problem. The
comments in the code explain how to reproduces the problem. There is also an
example of how a small tweak hides the problem.

Udi


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

* [Bug c/56608] built-in floor function returns false results when build with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
@ 2013-03-13  2:56 ` udifuchs at gmail dot com
  2013-03-13  3:27 ` [Bug tree-optimization/56608] SLP seems to produce incorrect value " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: udifuchs at gmail dot com @ 2013-03-13  2:56 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from udifuchs at gmail dot com 2013-03-13 02:56:37 UTC ---
Created attachment 29659
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29659
Testcase


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

* [Bug tree-optimization/56608] SLP seems to produce incorrect value with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
  2013-03-13  2:56 ` [Bug c/56608] " udifuchs at gmail dot com
@ 2013-03-13  3:27 ` pinskia at gcc dot gnu.org
  2013-03-13  9:08 ` [Bug tree-optimization/56608] [4.7/4.8 Regression] " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-03-13  3:27 UTC (permalink / raw)
  To: gcc-bugs


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization
            Summary|built-in floor function     |SLP seems to produce
                   |returns false results when  |incorrect value with
                   |build with -ffast-math      |-ffast-math

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-03-13 03:27:07 UTC ---
I don't think this has anything to do with floor/ceil folding but rather the
SLP pass is going wrong somewhere.


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

* [Bug tree-optimization/56608] [4.7/4.8 Regression] SLP seems to produce incorrect value with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
  2013-03-13  2:56 ` [Bug c/56608] " udifuchs at gmail dot com
  2013-03-13  3:27 ` [Bug tree-optimization/56608] SLP seems to produce incorrect value " pinskia at gcc dot gnu.org
@ 2013-03-13  9:08 ` rguenth at gcc dot gnu.org
  2013-03-13 10:44 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-13  9:08 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
      Known to work|                            |4.6.4
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2013-03-13
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1
            Summary|SLP seems to produce        |[4.7/4.8 Regression] SLP
                   |incorrect value with        |seems to produce incorrect
                   |-ffast-math                 |value with -ffast-math
   Target Milestone|---                         |4.7.3
      Known to fail|                            |4.7.3, 4.8.0

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-13 09:08:04 UTC ---
Confirmed.  Note we also generate non-optimal code in that we keep both
the vectorized and non-vectorized paths:

  _81 = (int) _80;
  uf_15(D)->autoCropHeight = _81;
...
  _84 = (double) _81;
  _85 = _83 / _84;
  if (aspectRatio_20 < _85)
    goto <bb 9>;
  else
    goto <bb 10>;

  <bb 9>:
  _86 = _84 * aspectRatio_20;
  _87 = _86 + 5.0e-1;
  _88 = __builtin_ifloor (_87);

and vectorized:

  vect_p.26_224 = &uf_15(D)->rotatedHeight;
  MEM[(struct ufraw_data *)vect_p.26_224] = vect_var_.22_217;

instead of re-loading the scalars from the vector.  That is, when
looking for scalar stores we start the SLP instance from we fail to
verify that no uses of the scalars in the instance remain after
vectorization.  Or if they remain, we fail to replace them with
vector extracts.

Not sure yet what's the wrong code issue (nothing obvious yet, still
investigating).


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

* [Bug tree-optimization/56608] [4.7/4.8 Regression] SLP seems to produce incorrect value with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
                   ` (2 preceding siblings ...)
  2013-03-13  9:08 ` [Bug tree-optimization/56608] [4.7/4.8 Regression] " rguenth at gcc dot gnu.org
@ 2013-03-13 10:44 ` rguenth at gcc dot gnu.org
  2013-03-13 12:16 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-13 10:44 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-13 10:43:23 UTC ---
Ick.  SLP replaces

  scale_51 = sqrt (_50);

with

  scale_51 = 0.0;

but has not eliminated all uses of it.  I have a simple fix, but really
I see no reason why DCE should not be able to remove the scalar calls given

  /* We only handle functions that do not read or clobber memory -- i.e.
     const or novops ones.  */
  if (!(gimple_call_flags (call) & (ECF_CONST | ECF_NOVOPS)))
    return NULL_TREE;


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

* [Bug tree-optimization/56608] [4.7/4.8 Regression] SLP seems to produce incorrect value with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
                   ` (3 preceding siblings ...)
  2013-03-13 10:44 ` rguenth at gcc dot gnu.org
@ 2013-03-13 12:16 ` rguenth at gcc dot gnu.org
  2013-03-13 13:16 ` [Bug tree-optimization/56608] [4.7 " rguenth at gcc dot gnu.org
  2013-03-26 10:16 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-13 12:16 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-13 12:15:22 UTC ---
Author: rguenth
Date: Wed Mar 13 12:15:06 2013
New Revision: 196632

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196632
Log:
2013-03-13  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/56608
    * tree-vect-slp.c (vect_schedule_slp): Do not remove scalar
    calls when vectorizing basic-blocks.

    * gcc.dg/vect/fast-math-bb-slp-call-3.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/vect/fast-math-bb-slp-call-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-slp.c


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

* [Bug tree-optimization/56608] [4.7 Regression] SLP seems to produce incorrect value with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
                   ` (4 preceding siblings ...)
  2013-03-13 12:16 ` rguenth at gcc dot gnu.org
@ 2013-03-13 13:16 ` rguenth at gcc dot gnu.org
  2013-03-26 10:16 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-13 13:16 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.0
            Summary|[4.7/4.8 Regression] SLP    |[4.7 Regression] SLP seems
                   |seems to produce incorrect  |to produce incorrect value
                   |value with -ffast-math      |with -ffast-math
      Known to fail|4.8.0                       |

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-13 13:16:23 UTC ---
Fixed for trunk for now.


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

* [Bug tree-optimization/56608] [4.7 Regression] SLP seems to produce incorrect value with -ffast-math
  2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
                   ` (5 preceding siblings ...)
  2013-03-13 13:16 ` [Bug tree-optimization/56608] [4.7 " rguenth at gcc dot gnu.org
@ 2013-03-26 10:16 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-26 10:16 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |4.7.3
         Resolution|                            |FIXED
      Known to fail|4.7.3                       |4.7.2

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-26 10:16:08 UTC ---
Author: rguenth
Date: Tue Mar 26 10:12:52 2013
New Revision: 197096

URL: http://gcc.gnu.org/viewcvs?rev=197096&root=gcc&view=rev
Log:
2013-03-26  Richard Biener  <rguenther@suse.de>

        Backport from mainline
        2013-03-13  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/56608
    * tree-vect-slp.c (vect_schedule_slp): Do not remove scalar
    calls when vectorizing basic-blocks.

    * gcc.dg/vect/fast-math-bb-slp-call-3.c: New testcase.

        2013-03-05  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/56270
    * tree-vect-slp.c (vect_schedule_slp): Clear vectorized stmts
    of loads after scheduling an SLP instance.

    * gcc.dg/vect/slp-38.c: New testcase.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/vect/fast-math-bb-slp-call-3.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/vect/slp-38.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-vect-slp.c


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

end of thread, other threads:[~2013-03-26 10:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-13  2:55 [Bug c/56608] New: built-in floor function returns false results when build with -ffast-math udifuchs at gmail dot com
2013-03-13  2:56 ` [Bug c/56608] " udifuchs at gmail dot com
2013-03-13  3:27 ` [Bug tree-optimization/56608] SLP seems to produce incorrect value " pinskia at gcc dot gnu.org
2013-03-13  9:08 ` [Bug tree-optimization/56608] [4.7/4.8 Regression] " rguenth at gcc dot gnu.org
2013-03-13 10:44 ` rguenth at gcc dot gnu.org
2013-03-13 12:16 ` rguenth at gcc dot gnu.org
2013-03-13 13:16 ` [Bug tree-optimization/56608] [4.7 " rguenth at gcc dot gnu.org
2013-03-26 10:16 ` 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).