public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
@ 2004-09-21  1:56 danglin at gcc dot gnu dot org
  2004-09-21  4:33 ` [Bug tree-optimization/17578] " danglin at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2004-09-21  1:56 UTC (permalink / raw)
  To: gcc-bugs

FAIL: gcc.c-torture/execute/ieee/compare-fp-3.c compilation,  -O1 
UNRESOLVED: gcc.c-torture/execute/ieee/compare-fp-3.c execution,  -O1 
FAIL: gcc.c-torture/execute/ieee/compare-fp-3.c compilation,  -O2 
UNRESOLVED: gcc.c-torture/execute/ieee/compare-fp-3.c execution,  -O2 
FAIL: gcc.c-torture/execute/ieee/compare-fp-3.c compilation,  -O3 -fomit-frame-
pointer 
UNRESOLVED: gcc.c-torture/execute/ieee/compare-fp-3.c execution,  -O3 -fomit-
frame-pointer 
FAIL: gcc.c-torture/execute/ieee/compare-fp-3.c compilation,  -O3 -g 
UNRESOLVED: gcc.c-torture/execute/ieee/compare-fp-3.c execution,  -O3 -g 
FAIL: gcc.c-torture/execute/ieee/compare-fp-3.c compilation,  -Os 
UNRESOLVED: gcc.c-torture/execute/ieee/compare-fp-3.c execution,  -Os

/tmp/ccKC9FUM.o(.text+0x30): In function `test1':
: undefined reference to `link_error0'
collect2: ld returned 1 exit status

The failures first appeared with the following change:

2004-09-02  James E Wilson  <wilson@specifixinc.com>

        * common.opt (ftrapping-math): Default to on.

The tests don't fail with -fno-trapping-math.

This is the function that doesn't optimize:

void
test1 (float x, float y)
{
  if ((x==y) && (x!=y))
    link_error0();
}

It is the only pair of comparisons in this test that isn't correctly
optimized.  The others are correctly optimized prior to the initial
RTL generation.

The generated code for this function is ok.  It's just not optimized.
As far as I can tell, neither comparison should trap, so -ftrapping-math
shouldn't affect the optimization.  This is the generated code at -O1.

        .text
        .align 4
.globl test1
        .type   test1, @function
test1:
        .PROC
        .CALLINFO FRAME=64,CALLS,SAVE_RP
        .ENTRY
        stw %r2,-20(%r30)
        fcmp,sgl,!= %fr4L,%fr5L
        ftest
        b .L4
        ldo 64(%r30),%r30
        b .L7
        ldw -84(%r30),%r2
.L4:
        fcmp,sgl,= %fr4L,%fr5L
        ftest
        b .L6
        ldw -84(%r30),%r2
        b,n .L7
.L6:
        bl link_error0,%r2
        nop
        ldw -84(%r30),%r2
.L7:
        bv %r0(%r2)
        ldo -64(%r30),%r30
        .EXIT
        .PROCEND
        .size   test1, .-test1

This doesn't appear to be a regression as 3.4 doesn't optimize this
function either.

I've added Roger and Paolo to the cc list as they worked on this
optimization.

-- 
           Summary: Missed optimization--failure of gcc.c-
                    torture/execute/ieee/compare-fp-3.c at -O1 and above
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: danglin at gcc dot gnu dot org
                CC: bonzini at gnu dot org,gcc-bugs at gcc dot gnu dot
                    org,roger at eyesopen dot com
 GCC build triplet: hppa-unknown-linux-gnu
  GCC host triplet: hppa-unknown-linux-gnu
GCC target triplet: hppa-unknown-linux-gnu


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
@ 2004-09-21  4:33 ` danglin at gcc dot gnu dot org
  2004-09-21  4:35 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2004-09-21  4:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From danglin at gcc dot gnu dot org  2004-09-21 04:33 -------
> The generated code for this function is ok.  It's just not optimized.
> As far as I can tell, neither comparison should trap, so -ftrapping-math
> shouldn't affect the optimization.

I take this back.  The compares can trap if x or y is a signalling NaN.
Thus, the compares can't be optimized without -fno-trapping-math.

I see gcc.c-torture/execute/ieee/compare-fp-3.x tries to set -fno-trapping-math
but it doesn't work.  For example,

Executing on host: /home/dave/gnu/gcc-4.0/objdir/gcc/xgcc -B/home/dave/gnu/gcc-4
.0/objdir/gcc/ /home/dave/gnu/gcc-4.0/gcc/gcc/testsuite/gcc.c-torture/execute/ie
ee/compare-fp-3.c  -w  -O1  -ffloat-store  -lm   -o /home/dave/gnu/gcc-4.0/objdi
r/gcc/testsuite/compare-fp-3.x1    (timeout = 300)
PASS: gcc.c-torture/execute/ieee/compare-fp-3.c compilation,  -O1
PASS: gcc.c-torture/execute/ieee/compare-fp-3.c execution,  -O1

On x86, link_error0 get optimized away in the compare-fp-3.c.16.life
pass.

There seems to be a bunch of bugs here.  We have link_error0 being
optimized away in test2 and test3 during tree optimization when
-fno-trapping-math is not set.  link_error0 is also being optimized
away in the life pass on x86 with -fno-trapping-math not set.  The
test isn't using the -fno-trapping-math.


-- 


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
  2004-09-21  4:33 ` [Bug tree-optimization/17578] " danglin at gcc dot gnu dot org
@ 2004-09-21  4:35 ` pinskia at gcc dot gnu dot org
  2004-09-21  6:20 ` dave at hiauly1 dot hia dot nrc dot ca
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-21  4:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-21 04:35 -------
Actually by the C standard, compares do not trap at all.

-- 


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
  2004-09-21  4:33 ` [Bug tree-optimization/17578] " danglin at gcc dot gnu dot org
  2004-09-21  4:35 ` pinskia at gcc dot gnu dot org
@ 2004-09-21  6:20 ` dave at hiauly1 dot hia dot nrc dot ca
  2004-09-23  3:18 ` danglin at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dave at hiauly1 dot hia dot nrc dot ca @ 2004-09-21  6:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dave at hiauly1 dot hia dot nrc dot ca  2004-09-21 06:20 -------
Subject: Re:  Missed optimization--failure of gcc

> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-21
> 04:35 -------
> Actually by the C standard, compares do not trap at all.

C99 indicates that relational operations may raise the invalid exception
when argument values are NaNs.  This includes both quiet and signalling NaNs.
5.2.4.2.2 paragraph 3 states that a signalling NaN generally raises an
exception when used as an arithmetic operand.  As far as I can tell, there
is no exception in this regard for the equality operators.  They are
analogous to the relational operators except for being lower in precedence.

Treating relational operators and equality operators differently with
respect to signalling NaNs would present a significant problem on the
PA-RISC architecture as all floating point comparisons behave in the
same manner.

>From the C standard, it's somewhat ambiguous whether a quiet NaN
should raise an exception in an equality operation.  We currently
don't raise an exception on the PA.

The C standard allows for various floating point models but I don't
think it was intended to be incompatible with IEC 60559:1989.  There
are various "is" macros which don't raise the invalid exception.

Dave


-- 


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-09-21  6:20 ` dave at hiauly1 dot hia dot nrc dot ca
@ 2004-09-23  3:18 ` danglin at gcc dot gnu dot org
  2004-12-23  2:11 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2004-09-23  3:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From danglin at gcc dot gnu dot org  2004-09-23 03:17 -------
> > The generated code for this function is ok.  It's just not optimized.
> > As far as I can tell, neither comparison should trap, so -ftrapping-math
> > shouldn't affect the optimization.
>
> I take this back.  The compares can trap if x or y is a signalling NaN.
> Thus, the compares can't be optimized without -fno-trapping-math.

It seems that the default for flag_signaling_nans is 0.  The equality and
inequality operators are not supposed to trap on a quiet NaN.  Thus, test1
should be optimized without the -fno-trapping_math option.  See the node
description for EQ_EXPR and NE_EXPR in doc/c-tree.texi.  Currently, it is
not being optimized at the tree level on either hppa-unknown-linux-gnu or
i686-pc-linux-gnu.

On the otherhand, LT_EXPR, LE_EXPR, GT_EXPR, GE_EXPR and possibly LTGT_EXPR
can cause an invalid exception if one of the operands is a quiet NaN.  Thus,
the following two functions shouldn't be optimized without -fno-trapping_math:

void
test2 (float x, float y)
{
  if ((x<y) && (x>y))
    link_error0();
}

void
test3 (float x, float y)
{
  if ((x<y) && (y<x))
    link_error0();
}

However, these two functions are being optimized at the tree level.



-- 


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-09-23  3:18 ` danglin at gcc dot gnu dot org
@ 2004-12-23  2:11 ` pinskia at gcc dot gnu dot org
  2004-12-26 20:49 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-23  2:11 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-23 02:10:58
               date|                            |


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-12-23  2:11 ` pinskia at gcc dot gnu dot org
@ 2004-12-26 20:49 ` cvs-commit at gcc dot gnu dot org
  2004-12-26 21:00 ` danglin at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-26 20:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-12-26 20:49 -------
Subject: Bug 17578

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	danglin@gcc.gnu.org	2004-12-26 20:49:15

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.c-torture/execute/ieee: compare-fp-3.x 
	                                          compare-fp-4.x 

Log message:
	PR tree-optimization/17578
	* gcc.c-torture/execute/ieee/compare-fp-3.x: Append -fno-trapping-math
	to additional_flags.
	* gcc.c-torture/execute/ieee/compare-fp-4.x: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4816&r2=1.4817
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-3.x.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-4.x.diff?cvsroot=gcc&r1=1.1&r2=1.2



-- 


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-12-26 20:49 ` cvs-commit at gcc dot gnu dot org
@ 2004-12-26 21:00 ` danglin at gcc dot gnu dot org
  2005-01-07 14:15 ` pinskia at gcc dot gnu dot org
  2005-01-15  5:26 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2004-12-26 21:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From danglin at gcc dot gnu dot org  2004-12-26 21:00 -------
Fixed by patch.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-12-26 21:00 ` danglin at gcc dot gnu dot org
@ 2005-01-07 14:15 ` pinskia at gcc dot gnu dot org
  2005-01-15  5:26 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-07 14:15 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


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

* [Bug tree-optimization/17578] Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above
  2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2005-01-07 14:15 ` pinskia at gcc dot gnu dot org
@ 2005-01-15  5:26 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-15  5:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-15 05:26 -------
*** Bug 19085 has been marked as a duplicate of this bug. ***

-- 


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


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

end of thread, other threads:[~2005-01-15  5:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-21  1:56 [Bug tree-optimization/17578] New: Missed optimization--failure of gcc.c-torture/execute/ieee/compare-fp-3.c at -O1 and above danglin at gcc dot gnu dot org
2004-09-21  4:33 ` [Bug tree-optimization/17578] " danglin at gcc dot gnu dot org
2004-09-21  4:35 ` pinskia at gcc dot gnu dot org
2004-09-21  6:20 ` dave at hiauly1 dot hia dot nrc dot ca
2004-09-23  3:18 ` danglin at gcc dot gnu dot org
2004-12-23  2:11 ` pinskia at gcc dot gnu dot org
2004-12-26 20:49 ` cvs-commit at gcc dot gnu dot org
2004-12-26 21:00 ` danglin at gcc dot gnu dot org
2005-01-07 14:15 ` pinskia at gcc dot gnu dot org
2005-01-15  5:26 ` pinskia 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).