public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/38478]  New: incorrect results for polynomial evaluation with optimisation/inline functions
@ 2008-12-10 17:22 bjg at gnu dot org
  2008-12-10 17:23 ` [Bug regression/38478] " bjg at gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bjg at gnu dot org @ 2008-12-10 17:22 UTC (permalink / raw)
  To: gcc-bugs

The attached program produces incorrect results in gcc-4.3.2 with -O2. (The
results are correct at -O0 when inline functions are not used).

The code evaluates a complex polynomial in Horner form via an inline function.
It is part of the test suite of gsl-1.11 (GNU Scientific Library).  I have
examined the code and believe it is numerically correct.  For comparison, the
problem does not occur in gcc-4.3.0.

$ /opt/gcc-4.3.2/bin/gcc -v      
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/bjg/ftp/gcc-4.3.2/configure --prefix=/opt/gcc-4.3.2
Thread model: posix
gcc version 4.3.2 (GCC) 

$ /opt/gcc-4.3.2/bin/gcc -O0 -Wall testcase.c 
$ ./a.out 
Completed [10/10]

$ /opt/gcc-4.3.2/bin/gcc -O2 -Wall testcase.c
$ ./a.out 
FAIL: y.real, gsl_complex_poly_complex_eval ({-2.31 + 0.44i, 4.21 - 3.19i, 0.93
+ 1.04i, -0.42 + 0.68i}, 0.49 + 0.95i) (-2.31000000000000005 observed vs
1.82462012000000007 expected) [9]
FAIL: y.imag, gsl_complex_poly_complex_eval ({-2.31 + 0.44i, 4.21 - 3.19i, 0.93
+ 1.04i, -0.42 + 0.68i}, 0.49 + 0.95i) (0.440000000000000002 observed vs
2.30389411999999982 expected) [10]


-- 
           Summary: incorrect results for polynomial evaluation with
                    optimisation/inline functions
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bjg at gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug regression/38478] incorrect results for polynomial evaluation with optimisation/inline functions
  2008-12-10 17:22 [Bug regression/38478] New: incorrect results for polynomial evaluation with optimisation/inline functions bjg at gnu dot org
@ 2008-12-10 17:23 ` bjg at gnu dot org
  2008-12-10 18:16 ` [Bug tree-optimization/38478] [4.3 Regression] " rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bjg at gnu dot org @ 2008-12-10 17:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bjg at gnu dot org  2008-12-10 17:22 -------
Created an attachment (id=16875)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16875&action=view)
example program (preprocessed)


-- 


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


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

* [Bug tree-optimization/38478] [4.3 Regression] incorrect results for polynomial evaluation with optimisation/inline functions
  2008-12-10 17:22 [Bug regression/38478] New: incorrect results for polynomial evaluation with optimisation/inline functions bjg at gnu dot org
  2008-12-10 17:23 ` [Bug regression/38478] " bjg at gnu dot org
@ 2008-12-10 18:16 ` rguenth at gcc dot gnu dot org
  2008-12-10 18:37 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-10 18:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-12-10 18:14 -------
field-sensitive PTA is the trigger.  Fails also at -O --param
max-fields-for-field-sensitive=100.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
          Component|regression                  |tree-optimization
           Keywords|                            |wrong-code
      Known to fail|                            |4.3.2
      Known to work|                            |4.2.4 4.4.0
            Summary|incorrect results for       |[4.3 Regression] incorrect
                   |polynomial evaluation with  |results for polynomial
                   |optimisation/inline         |evaluation with
                   |functions                   |optimisation/inline
                   |                            |functions
   Target Milestone|---                         |4.3.3


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


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

* [Bug tree-optimization/38478] [4.3 Regression] incorrect results for polynomial evaluation with optimisation/inline functions
  2008-12-10 17:22 [Bug regression/38478] New: incorrect results for polynomial evaluation with optimisation/inline functions bjg at gnu dot org
  2008-12-10 17:23 ` [Bug regression/38478] " bjg at gnu dot org
  2008-12-10 18:16 ` [Bug tree-optimization/38478] [4.3 Regression] " rguenth at gcc dot gnu dot org
@ 2008-12-10 18:37 ` rguenth at gcc dot gnu dot org
  2008-12-10 18:45 ` rguenth at gcc dot gnu dot org
  2008-12-10 18:47 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-10 18:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-12-10 18:35 -------
This looks the same as PR37868 (or more specifically it matches PR38048, a dup
of that).  Indeed, on the branch with -O2 it works.  But it seems to be still
broken with -O --param max-fields-for-field-sensitive=100 (but we shouldn't
care too much about that - this setting may be broken anyway).

optimized dump difference reveals that we remove initializations over-eagerly:

 <bb 2>:
-  c[0] = 1.0e+0;
-  c[1] = 5.0e-1;
-  c[2] = 2.99999999999999988897769753748434595763683319092e-1;
-  D.3671 = (c[1] + 1.49999999999999994448884876874217297881841659546e-1) *
5.0e
-1;
-  gsl_test_rel (c[0] + D.3671,
1.3249999999999999555910790149937383830547332763
7e+0, 2.220446049250313080847263336181640625e-14, &"gsl_poly_eval({1, 0.5,
0.3},
 0.5)"[0]);
+  D.3656 = (c[1] + 1.49999999999999994448884876874217297881841659546e-1) *
5.0e-1;
+  gsl_test_rel (c[0] + D.3656,
1.32499999999999995559107901499373838305473327637e+0,
2.220446049250313080847263336181640625e-14, &"gsl_poly_eval({1, 0.5, 0.3},
0.5)"[0]);

so, this may be related to PR38051 / PR38169.  I'm checking the backport
I have around.  Yup, that fixes it fully.  Mine.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-12-10 18:35:39
               date|                            |


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


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

* [Bug tree-optimization/38478] [4.3 Regression] incorrect results for polynomial evaluation with optimisation/inline functions
  2008-12-10 17:22 [Bug regression/38478] New: incorrect results for polynomial evaluation with optimisation/inline functions bjg at gnu dot org
                   ` (2 preceding siblings ...)
  2008-12-10 18:37 ` rguenth at gcc dot gnu dot org
@ 2008-12-10 18:45 ` rguenth at gcc dot gnu dot org
  2008-12-10 18:47 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-10 18:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-12-10 18:44 -------
Subject: Bug 38478

Author: rguenth
Date: Wed Dec 10 18:42:36 2008
New Revision: 142655

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142655
Log:
2008-12-10  Richard Guenther  <rguenther@suse.de>

        Backport from trunk the fix for PR38051.

        PR tree-optimization/38478
        * tree-ssa-structalias.c (update_alias_info): Manually find
        written variables.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/tree-ssa-structalias.c


-- 


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


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

* [Bug tree-optimization/38478] [4.3 Regression] incorrect results for polynomial evaluation with optimisation/inline functions
  2008-12-10 17:22 [Bug regression/38478] New: incorrect results for polynomial evaluation with optimisation/inline functions bjg at gnu dot org
                   ` (3 preceding siblings ...)
  2008-12-10 18:45 ` rguenth at gcc dot gnu dot org
@ 2008-12-10 18:47 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-10 18:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-12-10 18:43 -------
Fixed for 4.3.3.  (and dup of PR38051)

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


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-12-10 18:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-10 17:22 [Bug regression/38478] New: incorrect results for polynomial evaluation with optimisation/inline functions bjg at gnu dot org
2008-12-10 17:23 ` [Bug regression/38478] " bjg at gnu dot org
2008-12-10 18:16 ` [Bug tree-optimization/38478] [4.3 Regression] " rguenth at gcc dot gnu dot org
2008-12-10 18:37 ` rguenth at gcc dot gnu dot org
2008-12-10 18:45 ` rguenth at gcc dot gnu dot org
2008-12-10 18:47 ` rguenth at gcc dot gnu dot 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).