[Bug middle-end/19953] New: Special-case real*complex multiplication for flag_complex_method=2

Thomas dot Koenig at online dot de gcc-bugzilla@gcc.gnu.org
Mon Feb 14 20:06:00 GMT 2005


Looking at the following piece of code:

#include <math.h>
#include <complex.h>

int main()
{
    float a;
    complex float b,c;
    foo(&a, &b);
    c = a*b;
    return creal(c)+cimag(c)<0;
}

and compiling this with flag_complex_method=2 and -O3, I find
that the statement is translated to (in t65.optimized) to

  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  #   aD.2211_25 = V_MAY_DEF <aD.2211_1>;
  #   bD.2212_26 = V_MAY_DEF <bD.2212_7>;
  foo (&aD.2211, &bD.2212);
  #   D.2217_11 = V_MUST_DEF <D.2217_10>;
  D.2217 = __mulsc3 (aD.2211, 0.0, REALPART_EXPR <bD.2212>, IMAGPART_EXPR
<bD.2212>);
  return (doubleD.24) REALPART_EXPR <D.2217> + (doubleD.24) IMAGPART_EXPR
<D.2217> < 0.0;
  # SUCC: EXIT [100.0%]

This costs quite a lot of performance.  Multiplying a real number
by a complex number doesn't require any special cases, so the whole
__mulsc3 machinery is not needed here.

$ gcc -v
Using built-in specs.
Target: ia64-unknown-linux-gnu
Configured with: ../gcc-4.0-20050213/configure --prefix=/home/zfkts
--enable-languages=c,f95
Thread model: posix
gcc version 4.0.0 20050213 (experimental)

-- 
           Summary: Special-case real*complex multiplication for
                    flag_complex_method=2
           Product: gcc
           Version: 4.0.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=19953



More information about the Gcc-bugs mailing list