public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
@ 2004-12-24 19:23 pinskia at gcc dot gnu dot org
  2004-12-24 19:24 ` [Bug target/19150] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-24 19:23 UTC (permalink / raw)
  To: gcc-bugs

Take the following code:
double test (double x) {
        return 1.1 / x;
}

With -O2 -ffast-math with 2.95.3, we get:
        fldl    .LC0
        pushl   %ebp
        movl    %esp, %ebp
        fdivl   8(%ebp)
        popl    %ebp
        ret

But with 3.3, and 4.0:
        pushl   %ebp
        movl    %esp, %ebp
        fld1
        fdivl   8(%ebp)
        fmull   .LC1
        leave
        ret

-- 
           Summary: [3.3/3.4/4.0 Regression] suboptimal fp division with -
                    ffast-math
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug target/19150] [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
@ 2004-12-24 19:24 ` pinskia at gcc dot gnu dot org
  2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-24 19:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-24 19:24 -------
Likewise for:
double test (double x, double y) {
        return 5.1 / x + 5.2 / y;
}

Confirmed, this is just a split off from 14851.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-24 19:24:54
               date|                            |
   Target Milestone|---                         |3.4.4


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


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

* [Bug target/19150] [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
  2004-12-24 19:24 ` [Bug target/19150] " pinskia at gcc dot gnu dot org
  2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
@ 2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
  2005-01-27 19:53 ` Thomas dot Koenig at online dot de
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-24 19:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-24 19:26 -------
More from that bug:
Roger suggested to move the a/b -> a * (1.0/b) transformation from RTL to
tree-ssa (http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02017.html). In this
case, transformation could be enhanced to combine multiple divisions, as it is
explained in Agner Fog's "How to optimize for the Pentium family of
microprocessors", section 3.7.: a1/b1 + a2/b2 can be combined to (a1*b2 + a2*b1)
/ (b1*b2).

However, there is another bug exposed - when multiplying two constants from
constant pool, combiner combines two memory references into const_double.

-- 


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


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

* [Bug target/19150] [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
  2004-12-24 19:24 ` [Bug target/19150] " pinskia at gcc dot gnu dot org
@ 2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
  2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-24 19:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-24 19:26 -------
Note from that bug:
A proposed fix is here:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02193.html

By moving three-linked combine pass in front of two-linked pass, combiner has
considerably more freedom to simplify instructions.

Adding this to 17652 since the pending patch was considered too risky for stage3
(http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02241.html)


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uros at kss-loka dot si
OtherBugsDependingO|                            |17652
              nThis|                            |
           Keywords|                            |patch
   Target Milestone|3.4.4                       |4.0.0


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


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

* [Bug target/19150] [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
@ 2005-01-27 19:53 ` Thomas dot Koenig at online dot de
  2005-02-11  0:36 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-01-27 19:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From Thomas dot Koenig at online dot de  2005-01-27 19:52 -------
(In reply to comment #3)
> In this
> case, transformation could be enhanced to combine multiple divisions, as it is
> explained in Agner Fog's "How to optimize for the Pentium family of
> microprocessors", section 3.7.: a1/b1 + a2/b2 can be combined to (a1*b2 + a2*b1)
> / (b1*b2).

Unless this is combined with a check for overflow or underflow and
subdequent possiblity of correction

Consider the case where b1 > sqrt(HUGE_VAL).


-- 


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


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

* [Bug target/19150] [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-01-27 19:53 ` Thomas dot Koenig at online dot de
@ 2005-02-11  0:36 ` pinskia at gcc dot gnu dot org
  2005-02-14 15:04 ` uros at kss-loka dot si
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-11  0:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-10 21:13 -------
(In reply to comment #4)
> Unless this is combined with a check for overflow or underflow and
> subdequent possiblity of correction
> 
> Consider the case where b1 > sqrt(HUGE_VAL).

But this is with -ffast-math so ...

Lowering the priority since this is not known to show up in real code (yet).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3


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


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

* [Bug target/19150] [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-02-11  0:36 ` pinskia at gcc dot gnu dot org
@ 2005-02-14 15:04 ` uros at kss-loka dot si
  2005-04-12 17:38 ` [Bug target/19150] [3.3/3.4/4.0/4.1 " giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uros at kss-loka dot si @ 2005-02-14 15:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2005-02-14 07:03 -------
The patch for the problem described in description of this bug is actually at
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01928.html. There is an
inconsistency in simplify_binary_operation(), as decribed in b).

Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.204
diff -u -p -r1.204 simplify-rtx.c
--- simplify-rtx.c	9 Sep 2004 17:19:16 -0000	1.204
+++ simplify-rtx.c	20 Sep 2004 14:03:51 -0000
@@ -1309,7 +1309,10 @@ simplify_binary_operation (enum rtx_code
 	  REAL_ARITHMETIC (value, rtx_to_tree_code (code), f0, f1);
 
 	  value = real_value_truncate (mode, value);
-	  return CONST_DOUBLE_FROM_REAL_VALUE (value, mode);
+	  tem = CONST_DOUBLE_FROM_REAL_VALUE (value, mode);
+	  if (MEM_P (op0) || MEM_P (op1))
+	    tem = validize_mem (force_const_mem (mode, tem));
+	  return tem;
 	}
     }


-- 


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


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

* [Bug target/19150] [3.3/3.4/4.0/4.1 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-02-14 15:04 ` uros at kss-loka dot si
@ 2005-04-12 17:38 ` giovannibajo at libero dot it
  2005-04-13  9:59 ` uros at kss-loka dot si
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2005-04-12 17:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-04-12 17:38 -------
Uros, what's the state of this bug? I don't understand if the patch linked in 
comment #6 was committed, or which is its final version still pending 
review/approval.

-- 


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


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

* [Bug target/19150] [3.3/3.4/4.0/4.1 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2005-04-12 17:38 ` [Bug target/19150] [3.3/3.4/4.0/4.1 " giovannibajo at libero dot it
@ 2005-04-13  9:59 ` uros at kss-loka dot si
  2005-04-21  5:03 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uros at kss-loka dot si @ 2005-04-13  9:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2005-04-13 09:58 -------
(In reply to comment #7)
> Uros, what's the state of this bug? I don't understand if the patch linked in 
> comment #6 was committed, or which is its final version still pending 
> review/approval.

Another approach was suggested by Roger Sayle in
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02017.html. We would force
CONST_DOUBLE to memory only if (newly created) combined instruction with
CONST_DOUBLE operand doesn't match. However, this approach requires some more
hacking, and I havn't look into it (yet...?).

-- 


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


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

* [Bug target/19150] [3.3/3.4/4.0/4.1 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2005-04-13  9:59 ` uros at kss-loka dot si
@ 2005-04-21  5:03 ` mmitchel at gcc dot gnu dot org
  2005-07-08  1:42 ` [Bug target/19150] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-04-21  5:03 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

* [Bug target/19150] [3.4/4.0/4.1 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2005-04-21  5:03 ` mmitchel at gcc dot gnu dot org
@ 2005-07-08  1:42 ` mmitchel at gcc dot gnu dot org
  2005-08-17 12:36 ` [Bug target/19150] [3.4/4.0 " bonzini at gcc dot gnu dot org
  2005-09-05 15:46 ` [Bug target/19150] [3.4/4.0/4.1 " pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-07-08  1:42 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.1                       |4.0.2


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


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

* [Bug target/19150] [3.4/4.0 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2005-07-08  1:42 ` [Bug target/19150] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
@ 2005-08-17 12:36 ` bonzini at gcc dot gnu dot org
  2005-09-05 15:46 ` [Bug target/19150] [3.4/4.0/4.1 " pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-08-17 12:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bonzini at gcc dot gnu dot org  2005-08-17 12:29 -------
Now, on mainline, I get:

test:
        pushl   %ebp
        movl    %esp, %ebp
        fldl    .LC0
        fdivl   8(%ebp)
        leave
        ret


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.1.0
            Summary|[3.4/4.0/4.1 Regression]    |[3.4/4.0 Regression]
                   |suboptimal fp division with |suboptimal fp division with
                   |-ffast-math                 |-ffast-math


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


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

* [Bug target/19150] [3.4/4.0/4.1 Regression] suboptimal fp division with -ffast-math
  2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2005-08-17 12:36 ` [Bug target/19150] [3.4/4.0 " bonzini at gcc dot gnu dot org
@ 2005-09-05 15:46 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-05 15:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-05 15:45 -------
Just closing as fixed for 4.1 since this is not known to effect real code.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
            Summary|[3.4/4.0 Regression]        |[3.4/4.0/4.1 Regression]
                   |suboptimal fp division with |suboptimal fp division with
                   |-ffast-math                 |-ffast-math
   Target Milestone|4.0.2                       |4.1.0


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


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

end of thread, other threads:[~2005-09-05 15:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-24 19:23 [Bug target/19150] New: [3.3/3.4/4.0 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
2004-12-24 19:24 ` [Bug target/19150] " pinskia at gcc dot gnu dot org
2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
2004-12-24 19:26 ` pinskia at gcc dot gnu dot org
2005-01-27 19:53 ` Thomas dot Koenig at online dot de
2005-02-11  0:36 ` pinskia at gcc dot gnu dot org
2005-02-14 15:04 ` uros at kss-loka dot si
2005-04-12 17:38 ` [Bug target/19150] [3.3/3.4/4.0/4.1 " giovannibajo at libero dot it
2005-04-13  9:59 ` uros at kss-loka dot si
2005-04-21  5:03 ` mmitchel at gcc dot gnu dot org
2005-07-08  1:42 ` [Bug target/19150] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
2005-08-17 12:36 ` [Bug target/19150] [3.4/4.0 " bonzini at gcc dot gnu dot org
2005-09-05 15:46 ` [Bug target/19150] [3.4/4.0/4.1 " 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).