[Bug middle-end/20434] pessimization of complex expression

2006-01-31 Thread pinskia at gcc dot gnu dot org


-- 

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



[Bug middle-end/20434] pessimization of complex expression

2005-07-07 Thread tkoenig at gcc dot gnu dot org

--- 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


[Bug middle-end/20434] pessimization of complex expression

2005-03-12 Thread Thomas dot Koenig at online dot de

--- 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


[Bug middle-end/20434] pessimization of complex expression

2005-03-12 Thread pinskia at gcc dot gnu dot org

--- 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


[Bug middle-end/20434] pessimization of complex expression

2005-03-12 Thread Thomas dot Koenig at online dot de

--- 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


[Bug middle-end/20434] pessimization of complex expression

2005-03-11 Thread Thomas dot Koenig at online dot de

--- 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


Re: [Bug middle-end/20434] pessimization of complex expression

2005-03-11 Thread Andrew Pinski
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


[Bug middle-end/20434] pessimization of complex expression

2005-03-11 Thread pinskia at physics dot uc dot edu

--- 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


[Bug middle-end/20434] pessimization of complex expression

2005-03-11 Thread Thomas dot Koenig at online dot de

--- 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


[Bug middle-end/20434] pessimization of complex expression

2005-03-11 Thread pinskia at gcc dot gnu dot org

--- 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