public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/20434] New: pessimization of complex expression
@ 2005-03-11 21:56 Thomas dot Koenig at online dot de
2005-03-11 21:59 ` [Bug middle-end/20434] " Thomas dot Koenig at online dot de
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-03-11 21:56 UTC (permalink / raw)
To: gcc-bugs
$ cat complex-parts.c
#include <math.h>
#include <complex.h>
int main()
{
float cr,ci;
float complex c;
foo(&cr,&ci);
c = cr+I*ci;
return creal(c)+cimag(c)<0;
}
$ gcc -S -O2 -fdump-tree-optimized complex-parts.c
$ tail -10 complex-parts.c.t66.optimized
float D.2359;
float cr.18;
<bb 0>:
foo (&cr, &ci);
return (double) (cr + 0.0) + (double) (ci + 0.0) < 0.0;
}
$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1/configure --prefix=/home/ig25 --enable-languages=c,f95
Thread model: posix
gcc version 4.1.0 20050311 (experimental)
--
Summary: pessimization of complex expression
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Thomas dot Koenig at online dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
@ 2005-03-11 21:59 ` Thomas dot Koenig at online dot de
2005-03-11 22:41 ` Andrew Pinski
2005-03-11 22:41 ` pinskia at physics dot uc dot edu
` (6 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-03-11 21:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-03-11 21:59 -------
There are two strange things here:
- Why the + 0. ?
- Why the casts to double?
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:59 ` [Bug middle-end/20434] " Thomas dot Koenig at online dot de
@ 2005-03-11 22:41 ` Andrew Pinski
0 siblings, 0 replies; 11+ messages in thread
From: Andrew Pinski @ 2005-03-11 22:41 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
On Mar 11, 2005, at 4:59 PM, Thomas dot Koenig at online dot de wrote:
>
> ------- Additional Comments From Thomas dot Koenig at online dot de
> 2005-03-11 21:59 -------
> There are two strange things here:
>
> - Why the + 0. ?
>
> - Why the casts to double?
Because that is required by the C standard.
-- Pinski
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
2005-03-11 21:59 ` [Bug middle-end/20434] " Thomas dot Koenig at online dot de
@ 2005-03-11 22:41 ` pinskia at physics dot uc dot edu
2005-03-11 22:49 ` Thomas dot Koenig at online dot de
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: pinskia at physics dot uc dot edu @ 2005-03-11 22:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at physics dot uc dot edu 2005-03-11 22:41 -------
Subject: Re: pessimization of complex expression
On Mar 11, 2005, at 4:59 PM, Thomas dot Koenig at online dot de wrote:
>
> ------- Additional Comments From Thomas dot Koenig at online dot de
> 2005-03-11 21:59 -------
> There are two strange things here:
>
> - Why the + 0. ?
>
> - Why the casts to double?
Because that is required by the C standard.
-- Pinski
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
2005-03-11 21:59 ` [Bug middle-end/20434] " Thomas dot Koenig at online dot de
2005-03-11 22:41 ` pinskia at physics dot uc dot edu
@ 2005-03-11 22:49 ` Thomas dot Koenig at online dot de
2005-03-11 22:55 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-03-11 22:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-03-11 22:49 -------
> > - Why the casts to double?
> Because that is required by the C standard.
Isn't that covered by the as-if rule? I'm fairly
sure the cast to double won't change the result of
the "<" operator :-)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
` (2 preceding siblings ...)
2005-03-11 22:49 ` Thomas dot Koenig at online dot de
@ 2005-03-11 22:55 ` pinskia at gcc dot gnu dot org
2005-03-12 9:46 ` Thomas dot Koenig at online dot de
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-11 22:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-11 22:55 -------
(In reply to comment #3)
> > > - Why the casts to double?
> > Because that is required by the C standard.
>
> Isn't that covered by the as-if rule? I'm fairly
> sure the cast to double won't change the result of
> the "<" operator :-)
No but the addition is done in double.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
` (3 preceding siblings ...)
2005-03-11 22:55 ` pinskia at gcc dot gnu dot org
@ 2005-03-12 9:46 ` Thomas dot Koenig at online dot de
2005-03-12 18:07 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-03-12 9:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-03-12 09:45 -------
(In reply to comment #4)
> (In reply to comment #3)
> > > > - Why the casts to double?
> > > Because that is required by the C standard.
> >
> > Isn't that covered by the as-if rule? I'm fairly
> > sure the cast to double won't change the result of
> > the "<" operator :-)
> No but the addition is done in double.
Again, the as-if rule: If a and b are floats, the expression
a+b < 0 should be the same for any a and b regardless wether they
are done in float or double.
The same is true, for float a,b and c, of
c = a+b;
It is _not_ true for exmperssions like c = a+b-a, of course.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
` (4 preceding siblings ...)
2005-03-12 9:46 ` Thomas dot Koenig at online dot de
@ 2005-03-12 18:07 ` pinskia at gcc dot gnu dot org
2005-03-12 23:13 ` Thomas dot Koenig at online dot de
2005-07-07 9:14 ` tkoenig at gcc dot gnu dot org
7 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-12 18:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-12 18:07 -------
(In reply to comment #5)
> Again, the as-if rule: If a and b are floats, the expression
> a+b < 0 should be the same for any a and b regardless wether they
> are done in float or double.
Well the real reason is creal/cimag returns double and not float.
Use crealf/cimagf instead.
Well yes this is a missed optimization, which should be filed separately.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
` (5 preceding siblings ...)
2005-03-12 18:07 ` pinskia at gcc dot gnu dot org
@ 2005-03-12 23:13 ` Thomas dot Koenig at online dot de
2005-07-07 9:14 ` tkoenig at gcc dot gnu dot org
7 siblings, 0 replies; 11+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-03-12 23:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-03-12 23:13 -------
(In reply to comment #6)
> Well the real reason is creal/cimag returns double and not float.
> Use crealf/cimagf instead.
You're right, of course. Doing that gets me
<bb 0>:
foo (&cr, &ci);
return cr + 0.0 + ci + 0.0 < 0.0;
OK, the direct cast has gone away. I wonder if this still converts
to double, though...
> Well yes this is a missed optimization, which should be filed separately.
I think using crealf/cimagf pretty much solves this. If you lie to the
compiler... :-)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
` (6 preceding siblings ...)
2005-03-12 23:13 ` Thomas dot Koenig at online dot de
@ 2005-07-07 9:14 ` tkoenig at gcc dot gnu dot org
7 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-07-07 9:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tkoenig at gcc dot gnu dot org 2005-07-07 09:14 -------
This appears to be fixed now in mainline:
$ cat complex-parts.c
#include <math.h>
#include <complex.h>
int main()
{
float cr,ci;
float complex c;
foo(&cr,&ci);
c = cr+I*ci;
return crealf(c)+cimagf(c)<0;
}
$ gcc -S -O3 -fdump-tree-optimized complex-parts.c
$ tail -10 complex-parts.c.t82.optimized
<unnamed type> D.2371;
float cr.0;
<bb 0>:
foo (&cr, &ci);
return cr + ci < 0.0;
}
$ gcc -v
Using built-in specs.
Target: ia64-unknown-linux-gnu
Configured with: ../gcc-4.1-20050702/configure --prefix=/home/zfkts --enable-
languages=c,f95
Thread model: posix
gcc version 4.1.0 20050702 (experimental)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Known to work| |4.1.0
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/20434] pessimization of complex expression
[not found] <bug-20434-9515@http.gcc.gnu.org/bugzilla/>
@ 2006-01-31 18:20 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-31 18:20 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20434
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-01-31 18:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-11 21:56 [Bug middle-end/20434] New: pessimization of complex expression Thomas dot Koenig at online dot de
2005-03-11 21:59 ` [Bug middle-end/20434] " Thomas dot Koenig at online dot de
2005-03-11 22:41 ` Andrew Pinski
2005-03-11 22:41 ` pinskia at physics dot uc dot edu
2005-03-11 22:49 ` Thomas dot Koenig at online dot de
2005-03-11 22:55 ` pinskia at gcc dot gnu dot org
2005-03-12 9:46 ` Thomas dot Koenig at online dot de
2005-03-12 18:07 ` pinskia at gcc dot gnu dot org
2005-03-12 23:13 ` Thomas dot Koenig at online dot de
2005-07-07 9:14 ` tkoenig at gcc dot gnu dot org
[not found] <bug-20434-9515@http.gcc.gnu.org/bugzilla/>
2006-01-31 18:20 ` 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).