public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14851] New: suboptimal fp division
@ 2004-04-05 13:55 uros at kss-loka dot si
2004-04-05 15:06 ` [Bug optimization/14851] [3.5 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: uros at kss-loka dot si @ 2004-04-05 13:55 UTC (permalink / raw)
To: gcc-bugs
Floating point division in current CVS gcc expands x/x into (1/x)*x. This testcase:
double test(double x)
{
return x/x;
}
is with gcc 3.5.0 20040405 (experimental) with -O2 -ffast-math compiled to:
test:
pushl %ebp
movl %esp, %ebp
fldl 8(%ebp)
fld1
fdiv %st(1), %st
popl %ebp
fmulp %st, %st(1)
ret
And with gcc 3.2 20020903 (Red Hat Linux 8.0 3.2-7):
test:
pushl %ebp
movl %esp, %ebp
fldl 8(%ebp)
fdiv %st(0), %st
leave
ret
--
Summary: suboptimal fp division
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uros at kss-loka dot si
CC: gcc-bugs at gcc dot 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=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug optimization/14851] [3.5 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
@ 2004-04-05 15:06 ` pinskia at gcc dot gnu dot org
2004-09-17 6:08 ` [Bug rtl-optimization/14851] [4.0 " uros at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-05 15:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-05 15:05 -------
Confirmed, a regression from 3.4.0.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |pessimizes-code
Known to fail| |3.5.0
Known to work| |3.4.0
Last reconfirmed|0000-00-00 00:00:00 |2004-04-05 15:05:59
date| |
Summary|suboptimal fp division |[3.5 Regression] suboptimal
| |fp division with -ffast-math
Target Milestone|--- |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
2004-04-05 15:06 ` [Bug optimization/14851] [3.5 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
@ 2004-09-17 6:08 ` uros at gcc dot gnu dot org
2004-09-17 6:09 ` uros at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu dot org @ 2004-09-17 6:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at gcc dot gnu dot org 2004-09-17 06:08 -------
This is caused by following code in expr.c, around line 7676:
--cut here--
case RDIV_EXPR:
/* Emit a/b as a*(1/b). Later we may manage CSE the reciprocal saving
expensive divide. If not, combine will rebuild the original
computation. */
if (flag_unsafe_math_optimizations && optimize && !optimize_size
&& TREE_CODE (type) == REAL_TYPE
&& !real_onep (TREE_OPERAND (exp, 0)))
return expand_expr (build2 (MULT_EXPR, type, TREE_OPERAND (exp, 0),
build2 (RDIV_EXPR, type,
build_real (type, dconst1),
TREE_OPERAND (exp, 1))),
target, tmode, modifier);
--cut here--
It is obvious, that in current 4.0, combine is ignoring this construct.
BTW: gcc-3.3 has quite weird behaviour with testcases like the one above, when
numerator is constant. When dividing integer-like numerators (for example
123532.0 / x), combine converts expression back to original one, and for real
numerators (4241.432 / x), no conversion occurs.
I will try to fix mainline.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Known to fail|4.0 |4.0.0
Last reconfirmed|2004-07-09 03:49:33 |2004-09-17 06:08:21
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
2004-04-05 15:06 ` [Bug optimization/14851] [3.5 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
2004-09-17 6:08 ` [Bug rtl-optimization/14851] [4.0 " uros at gcc dot gnu dot org
@ 2004-09-17 6:09 ` uros at gcc dot gnu dot org
2004-09-21 5:11 ` cvs-commit at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu dot org @ 2004-09-17 6:09 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at gcc dot gnu dot org 2004-09-17 06:09 -------
Taking bug.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |uros at kss-loka dot si
|dot org |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (2 preceding siblings ...)
2004-09-17 6:09 ` uros at gcc dot gnu dot org
@ 2004-09-21 5:11 ` cvs-commit at gcc dot gnu dot org
2004-09-21 5:17 ` uros at kss-loka dot si
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-21 5:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-09-21 05:11 -------
Subject: Bug 14851
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: uros@gcc.gnu.org 2004-09-21 05:10:55
Modified files:
gcc : ChangeLog rtlanal.c
Log message:
PR rtl-optimization/14851
* rtlanal.c (commutative_operand_precedence): Calculate
precedence of stripped constant.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5543&r2=2.5544
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/rtlanal.c.diff?cvsroot=gcc&r1=1.200&r2=1.201
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (3 preceding siblings ...)
2004-09-21 5:11 ` cvs-commit at gcc dot gnu dot org
@ 2004-09-21 5:17 ` uros at kss-loka dot si
2004-09-27 9:19 ` uros at kss-loka dot si
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: uros at kss-loka dot si @ 2004-09-21 5:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2004-09-21 05:17 -------
CVS commit in comment #4 is only partial fix for this PR. Please look at
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01928.html
There are still troubles with testcases:
double test (double x) {
return 1.1 / x;
}
[A fix is proposed for above testcase]
and
double test (double x, double y) {
return 5.1 / x + 5.2 / y;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (4 preceding siblings ...)
2004-09-21 5:17 ` uros at kss-loka dot si
@ 2004-09-27 9:19 ` uros at kss-loka dot si
2004-10-04 7:51 ` bonzini at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: uros at kss-loka dot si @ 2004-09-27 9:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2004-09-27 09:19 -------
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.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (5 preceding siblings ...)
2004-09-27 9:19 ` uros at kss-loka dot si
@ 2004-10-04 7:51 ` bonzini at gcc dot gnu dot org
2004-10-04 9:40 ` giovannibajo at libero dot it
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2004-10-04 7:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bonzini at gcc dot gnu dot org 2004-10-04 07:51 -------
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
----------------------------------------------------------------------------
OtherBugsDependingO| |17652
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (6 preceding siblings ...)
2004-10-04 7:51 ` bonzini at gcc dot gnu dot org
@ 2004-10-04 9:40 ` giovannibajo at libero dot it
2004-10-05 5:58 ` uros at kss-loka dot si
2004-12-24 19:27 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-04 9:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-10-04 09:40 -------
OK, then we need to find another solution for 4.0.0, as this is a regression
from 3.4.0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (7 preceding siblings ...)
2004-10-04 9:40 ` giovannibajo at libero dot it
@ 2004-10-05 5:58 ` uros at kss-loka dot si
2004-12-24 19:27 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: uros at kss-loka dot si @ 2004-10-05 5:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2004-10-05 05:57 -------
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.
Uros.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/14851] [4.0 Regression] suboptimal fp division with -ffast-math
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
` (8 preceding siblings ...)
2004-10-05 5:58 ` uros at kss-loka dot si
@ 2004-12-24 19:27 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-24 19:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-24 19:27 -------
The orginal bug was fixed, the next bug is really a regression from 2.95.3 for all 3.3, 3.4.0, and 4.0.0.
I opened a new bug for that, PR 19150.
So I am closing as fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-12-24 19:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-05 13:55 [Bug optimization/14851] New: suboptimal fp division uros at kss-loka dot si
2004-04-05 15:06 ` [Bug optimization/14851] [3.5 Regression] suboptimal fp division with -ffast-math pinskia at gcc dot gnu dot org
2004-09-17 6:08 ` [Bug rtl-optimization/14851] [4.0 " uros at gcc dot gnu dot org
2004-09-17 6:09 ` uros at gcc dot gnu dot org
2004-09-21 5:11 ` cvs-commit at gcc dot gnu dot org
2004-09-21 5:17 ` uros at kss-loka dot si
2004-09-27 9:19 ` uros at kss-loka dot si
2004-10-04 7:51 ` bonzini at gcc dot gnu dot org
2004-10-04 9:40 ` giovannibajo at libero dot it
2004-10-05 5:58 ` uros at kss-loka dot si
2004-12-24 19:27 ` 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).