complex patch

Stephen L Moshier moshier@mediaone.net
Sun Jan 17 13:37:00 GMT 1999


Using today's egcs cvs, an alpha egcs with the
d-complex patch seems to do real float and real double functions
ok but dies on this float complex --

egcs-build/gcc/stage1/xgcc -Begcs-build/gcc/stage1/ -Iegcs-build/gcc/stage1/include  -g -O2 -Wall -I.   -c clogf.c -o clogf.o
clogf.c: In function `casinf':
clogf.c:557: internal error--unrecognizable insn:
(call_insn 282 279 284 (parallel[ 
            (set (concat:SC (reg:SF 32 $f0)
                    (reg:SF 33 $f1))
                (call (mem:DI (symbol_ref:DI ("csqrtf")) 0)
                    (const_int 0)))
            (clobber (reg:DI 27 $27))
            (clobber (reg:DI 26 $26))
        ] ) -1 (insn_list 277 (insn_list 279 (nil)))
    (expr_list:REG_DEAD (reg:SF 48 $f16)
        (expr_list:REG_DEAD (reg:SF 49 $f17)
            (expr_list:REG_UNUSED (reg:DI 27 $27)
                (expr_list:REG_UNUSED (reg:DI 26 $26)
                    (nil)))))
    (expr_list (use (reg:SF 49 $f17))
        (expr_list (use (reg:SF 48 $f16))
            (nil))))
../ccdir/gcc/toplev.c:1397: Internal compiler error in function fatal_insn
Please submit a full bug report to `egcs-bugs@cygnus.com'.
See <URL: http://egcs.cygnus.com/faq.html#bugreport > for details.
make: *** [clogf.o] Error 1

Here is the .i file to practice on.
-------------------------
# 1 "clogf.c"
 





































# 1 "complex.h" 1
 







 

 





 
 

 

 


extern double atan2 (double, double);


 


 




 

extern double cabs ( double __complex__  z );
extern double hypot ( double x, double y );

 

extern double __complex__  clog ( double __complex__  z );
extern double __complex__  cexp ( double __complex__  z );
extern double __complex__  csqrt ( double __complex__  z );
extern double __complex__  csin ( double __complex__  z );
extern double __complex__  ccos ( double __complex__  z );
extern double __complex__  ctan ( double __complex__  z );
extern double __complex__  ccot ( double __complex__  z );
extern double __complex__  casin ( double __complex__  z );
extern double __complex__  cacos ( double __complex__  z );
extern double __complex__  catan ( double __complex__  z );
extern double __complex__  csinh ( double __complex__  z );
extern double __complex__  casinh ( double __complex__  z );
extern double __complex__  ccosh ( double __complex__  z );
extern double __complex__  cacosh ( double __complex__  z );
extern double __complex__  ctanh ( double __complex__  z );
extern double __complex__  catanh ( double __complex__  z );
extern double __complex__  cpow (double __complex__  a, double __complex__  z);

 

extern double __complex__  cadd ( double __complex__  a, double __complex__  b );
extern double __complex__  csub ( double __complex__  a, double __complex__  b );
extern double __complex__  cmul ( double __complex__  a, double __complex__  b );
extern double __complex__  cdiv ( double __complex__  a, double __complex__  b );

 


extern float atan2f (float, float);

extern float cabsf ( float __complex__  z );
extern float __complex__  clogf ( float __complex__  z );
extern float __complex__  cexpf ( float __complex__  z );
extern float __complex__  csqrtf ( float __complex__  z );
extern float __complex__  csinf ( float __complex__  z );
extern float __complex__  ccosf ( float __complex__  z );
extern float __complex__  ctanf ( float __complex__  z );
extern float __complex__  ccotf ( float __complex__  z );
extern float __complex__  casinf ( float __complex__  z );
extern float __complex__  cacosf ( float __complex__  z );
extern float __complex__  catanf ( float __complex__  z );
extern float __complex__  csinhf ( float __complex__  z );
extern float __complex__  casinhf ( float __complex__  z );
extern float __complex__  ccoshf ( float __complex__  z );
extern float __complex__  cacoshf ( float __complex__  z );
extern float __complex__  ctanhf ( float __complex__  z );
extern float __complex__  catanhf ( float __complex__  z );
extern float __complex__  cpowf (float __complex__  a, float __complex__  z);



extern long double atan2l (long double, long double);

extern long double cabsl ( long double __complex__  z );
extern long double __complex__  clogl ( long double __complex__  z );
extern long double __complex__  cexpl ( long double __complex__  z );
extern long double __complex__  csqrtl ( long double __complex__  z );
extern long double __complex__  csinl ( long double __complex__  z );
extern long double __complex__  ccosl ( long double __complex__  z );
extern long double __complex__  ctanl ( long double __complex__  z );
extern long double __complex__  ccotl ( long double __complex__  z );
extern long double __complex__  casinl ( long double __complex__  z );
extern long double __complex__  cacosl ( long double __complex__  z );
extern long double __complex__  catanl ( long double __complex__  z );
extern long double __complex__  csinhl ( long double __complex__  z );
extern long double __complex__  casinhl ( long double __complex__  z );
extern long double __complex__  ccoshl ( long double __complex__  z );
extern long double __complex__  cacoshl ( long double __complex__  z );
extern long double __complex__  ctanhl ( long double __complex__  z );
extern long double __complex__  catanhl ( long double __complex__  z );
extern long double __complex__  cpowl (long double __complex__  a, long double __complex__  z);
extern float __complex__  clgamf ( float __complex__  z );
extern double __complex__  clgam ( double __complex__  z );
extern long double __complex__  clgaml ( long double __complex__  z );
extern float __complex__  cgammaf ( float __complex__  z );
extern double __complex__  cgamma ( double __complex__  z );
extern long double __complex__  cgammal ( long double __complex__  z );
# 39 "clogf.c" 2

# 1 "mconf.h" 1
 





























































 





 












 
typedef struct
	{
	double r;
	double i;
	}cmplx;

typedef struct
	{
	float r;
	float i;
	} cmplxf;

 

typedef struct
	{
	long double r;
	long double i;
	} cmplxl;

 

 

 

 

 

 


 

 







 


 




 








 
 

 










 

 


 


 



 


 


# 1 "protos.h" 1
 





extern double acosh ( double x );
extern int airy ( double x, double *ai, double *aip, double *bi, double *bip );
extern double asin ( double x );
extern double acos ( double x );
extern double asinh ( double x );
extern double atan ( double x );
extern double atan2 ( double y, double x );
extern double atanh ( double x );
extern double bdtrc ( int k, int n, double p );
extern double bdtr ( int k, int n, double p );
extern double bdtri ( int k, int n, double y );
extern double beta ( double a, double b );
extern double lbeta ( double a, double b );
extern double btdtr ( double a, double b, double x );
extern double cbrt ( double x );
extern double chbevl ( double x, void *P, int n );
extern double chdtrc ( double df, double x );
extern double chdtr ( double df, double x );
extern double chdtri ( double df, double y );
extern double cosh ( double x );
extern double dawsn ( double xx );
extern void eigens ( double A[], double RR[], double E[], int N );
extern double ellie ( double phi, double m );
extern double ellik ( double phi, double m );
extern double ellpe ( double x );
extern int ellpj ( double u, double m, double *sn, double *cn, double *dn, double *ph );
extern double ellpk ( double x );
extern double exp ( double x );
extern double exp10 ( double x );
extern double exp1m ( double x );
extern double exp2 ( double x );
extern double expn ( int n, double x );
extern double fabs ( double x );
extern double fac ( int i );
extern double fdtrc ( int ia, int ib, double x );
extern double fdtr ( int ia, int ib, double x );
extern double fdtri ( int ia, int ib, double y );
extern int fftr ( double x[], int m0, double sine[] );
extern double ceil ( double x );
extern double floor ( double x );
extern double frexp ( double x, int *pw2 );
extern double ldexp ( double x, int pw2 );
extern int signbit ( double x );
extern int isnan ( double x );
extern int isfinite ( double x );
extern int fresnl ( double xxa, double *ssa, double *cca );
extern double gamma ( double x );
extern double lgam ( double x );
extern double gdtr ( double a, double b, double x );
extern double gdtrc ( double a, double b, double x );
extern int gels ( double A[], double R[], int M, double EPS, double AUX[] );
extern double hyp2f1 ( double a, double b, double c, double x );
extern double hyperg ( double a, double b, double x );
extern double hyp2f0 ( double a, double b, double x, int type, double *err );
extern double i0 ( double x );
extern double i0e ( double x );
extern double i1 ( double x );
extern double i1e ( double x );
extern double igamc ( double a, double x );
extern double igam ( double a, double x );
extern double igami ( double a, double y0 );
extern double incbet ( double aa, double bb, double xx );
extern double incbi ( double aa, double bb, double yy0 );
extern double iv ( double v, double x );
extern double j0 ( double x );
extern double y0 ( double x );
extern double j1 ( double x );
extern double y1 ( double x );
extern double jn ( int n, double x );
extern double jv ( double n, double x );
extern double k0 ( double x );
extern double k0e ( double x );
extern double k1 ( double x );
extern double k1e ( double x );
extern double kn ( int nn, double x );
extern int levnsn ( int n, double r[], double a[], double e[], double refl[] );
extern double log ( double x );
extern double log10 ( double x );
extern double log2 ( double x );
extern long lrand ( void );
extern long lsqrt ( long x );
extern int minv ( double A[], double X[], int n, double B[], int IPS[] );
extern int mmmpy ( int r, int c, double *A, double *B, double *Y );
extern int mtherr ( char *name, int code );
extern double polevl ( double x, void *P, int N );
extern double p1evl ( double x, void *P, int N );
extern int mtransp ( int n, double *A, double *T );
extern int mvmpy ( int r, int c, double *A, double *V, double *Y );
extern double nbdtrc ( int k, int n, double p );
extern double nbdtr ( int k, int n, double p );
extern double nbdtri ( int k, int n, double p );
extern double ndtr ( double a );
extern double erfc ( double a );
extern double erf ( double x );
extern double ndtri ( double y0 );
extern double pdtrc ( int k, double m );
extern double pdtr ( int k, double m );
extern double pdtri ( int k, double y );
extern double pow ( double x, double y );
extern double powi ( double x, int nn );
extern double psi ( double x );
extern void revers ( double y[], double x[], int n );
extern double rgamma ( double x );
extern double round ( double x );
extern int sprec ( void );
extern int dprec ( void );
extern int ldprec ( void );
extern int shichi ( double x, double *si, double *ci );
extern int sici ( double x, double *si, double *ci );
extern double simpsn ( double f[], double delta );
extern int simq ( double A[], double B[], double X[], int n, int flag, int IPS[] );
extern double sin ( double x );
extern double cos ( double x );
extern double radian ( double d, double m, double s );
 


extern double sindg ( double x );
extern double cosdg ( double x );
extern double sinh ( double x );
extern double spence ( double x );
extern double sqrt ( double x );
extern double stdtr ( int k, double t );
extern double stdtri ( int k, double p );
extern double onef2 ( double a, double b, double c, double x, double *err );
extern double threef0 ( double a, double b, double c, double x, double *err );
extern double struve ( double v, double x );
extern double tan ( double x );
extern double cot ( double x );
extern double tandg ( double x );
extern double cotdg ( double x );
extern double tanh ( double x );
extern double log1p ( double x );
extern double expm1 ( double x );
extern double cosm1 ( double x );
extern double yn ( int n, double x );
extern double zeta ( double x, double q );
extern double zetac ( double x );
extern int drand ( double *a );

extern float floorf (float);
extern float logf (float);
extern float fabsf (float);
extern long double floorl (long double);
extern long double logl (long double);
extern long double fabsl (long double);
extern long double sinl (long double);
extern long double cosl (long double);
extern long double sqrtl (long double);
# 175 "mconf.h" 2





 
extern int merror;
# 40 "clogf.c" 2

extern float MAXNUMF, MACHEPF, PIF, PIO2F;

float cabsf(float __complex__ );
float sqrtf(float), logf(float);
float atan2f(float, float);
float expf(float), sinf(float), cosf(float);
float coshf(float), sinhf(float), asinf(float);
float ctansf(float __complex__ );
float redupif(float);
static void cchshf( float, float *, float * );
 
float __complex__  csqrtf( float __complex__  );
float powf (float, float);
# 63 "clogf.c"




float __complex__ 
clogf( float __complex__  z )
{
float __complex__  w;
float p, rr, x, y;

x = (__real__ ( z )) ;
y = (__imag__ ( z )) ;
rr = atan2f( y, x );
p = cabsf(z);
p = logf(p);
w = p + rr * (1.0fi)  ;
return (w);
}
 




































float __complex__ 
cexpf( float __complex__  z )
{
float __complex__  w;
float r;

r = expf( (__real__ ( z ))  );
w = r * cosf( (__imag__ ( z ))  ) +  r * sinf( (__imag__ ( z ))  ) * (1.0fi)  ;
return (w);
}
 

































float __complex__ 
csinf( float __complex__  z )
{
float __complex__  w;
float ch, sh;

cchshf( (float) (__imag__ ( z )) , &ch, &sh );
w = sinf( (__real__ ( z ))  ) * ch  + (cosf( (__real__ ( z ))  ) * sh) * (1.0fi)  ;
return (w);
}



 


static void
cchshf( float xx, float *c, float *s )





{
float x, e, ei;

x = xx;
if( ( ( x ) < 0 ? -( x ) : ( x ) )  <= 0.5f )
	{
	*c = coshf(x);
	*s = sinhf(x);
	}
else
	{
	e = expf(x);
	ei = 0.5f/e;
	e = 0.5f * e;
	*s = e - ei;
	*c = e + ei;
	}
}

 
































float __complex__ 
ccosf( float __complex__  z )
{
float __complex__  w;
float ch, sh;

cchshf( (__imag__ ( z )) , &ch, &sh );
w = cosf( (__real__ ( z ))  ) * ch + ( -sinf( (__real__ ( z ))  ) * sh) * (1.0fi)  ;
return (w);
}
 





































float __complex__ 
ctanf( float __complex__  z )
{
float __complex__  w;
float d;

d = cosf( 2.0f * (__real__ ( z ))  ) + coshf( 2.0f * (__imag__ ( z ))  );

if( ( ( d ) < 0 ? -( d ) : ( d ) )  < 0.25f )
	d = ctansf(z);

if( d == 0.0f )
	{
	mtherr( "ctanf", 3  );
	w = MAXNUMF + MAXNUMF * (1.0fi)  ;
	return (w);
	}
w = sinf (2.0f * (__real__ ( z )) ) / d + (sinhf (2.0f * (__imag__ ( z )) ) / d) * (1.0fi)  ;
return (w);
}
 






































float __complex__ 
ccotf( float __complex__  z )
{
float __complex__  w;
float d;


d = coshf(2.0f * (__imag__ ( z )) ) - cosf(2.0f * (__real__ ( z )) );

if( ( ( d ) < 0 ? -( d ) : ( d ) )  < 0.25f )
	d = ctansf(z);

if( d == 0.0f )
	{
	mtherr( "ccotf", 3  );
	w = MAXNUMF + MAXNUMF * (1.0fi)  ;
	return (w);
	}
w = sinf (2.0f * (__real__ ( z )) ) / d - (sinhf (2.0f * (__imag__ ( z )) ) / d) * (1.0fi)  ;
return (w);
}

 
 

static double DP1 =  3.140625;
static double DP2 =  9.67502593994140625E-4;
static double DP3 =  1.509957990978376432E-7;



float redupif(float xx)




{
float x, t;
long i;

x = xx;
t = x/PIF;
if( t >= 0.0 )
	t += 0.5;
else
	t -= 0.5;

i = t;	 
t = i;
t = ((x - t * DP1) - t * DP2) - t * DP3;
return(t);
}

 

float
ctansf(float __complex__  z)
{
float f, x, x2, y, y2, rn, t, d;

x = ( (  2.0f * (__real__ ( z ))   ) < 0 ? -(  2.0f * (__real__ ( z ))   ) : (  2.0f * (__real__ ( z ))   ) ) ;
y = ( (  2.0f * (__imag__ ( z ))   ) < 0 ? -(  2.0f * (__imag__ ( z ))   ) : (  2.0f * (__imag__ ( z ))   ) ) ;

x = redupif(x);

x = x * x;
y = y * y;
x2 = 1.0f;
y2 = 1.0f;
f = 1.0f;
rn = 0.0f;
d = 0.0f;
do
	{
	rn += 1.0f;
	f *= rn;
	rn += 1.0f;
	f *= rn;
	x2 *= x;
	y2 *= y;
	t = y2 + x2;
	t /= f;
	d += t;

	rn += 1.0f;
	f *= rn;
	rn += 1.0f;
	f *= rn;
	x2 *= x;
	y2 *= y;
	t = y2 - x2;
	t /= f;
	d += t;
	}
while( ( ( t/d ) < 0 ? -( t/d ) : ( t/d ) )  > MACHEPF );
return(d);
}
 































float __complex__ 
casinf( float __complex__  z )
{
float __complex__  w;
float x, y;
static float __complex__  ca, ct, zz, z2;
 





x = (__real__ ( z )) ;
y = (__imag__ ( z )) ;

if( y == 0.0f )
	{
	if( ( ( x ) < 0 ? -( x ) : ( x ) )  > 1.0f )
		{
		w = PIO2F + 0.0f * (1.0fi)  ;
		mtherr( "casinf", 1  );
		}
	else
		{
		w = asinf (x) + 0.0f * (1.0fi)  ;
		}
	return (w);
	}

 
 







































  ca = x + y * (1.0fi)  ;
  ct = ca * (1.0fi)  ;	 
	 
 
	 
  zz = (x - y) * (x + y) + (2.0f * x * y) * (1.0fi)  ;
  zz = 1.0f - (__real__ ( zz ))  - (__imag__ ( zz ))  * (1.0fi)  ;
  z2 = csqrtf (zz);

  zz = ct + z2;
  zz = clogf (zz);
   
  w = zz * (-1.0f * (1.0fi)  );
  return (w);
}
 






























float __complex__ 
cacosf( float __complex__  z )
{
float __complex__  w;

w = casinf( z );
w = (PIO2F  -  (__real__ ( w )) ) - (__imag__ ( w ))  * (1.0fi)  ;
return (w);
}
 











































float __complex__ 
catanf( float __complex__  z )
{
float __complex__  w;
float a, t, x, x2, y;

x = (__real__ ( z )) ;
y = (__imag__ ( z )) ;

if( (x == 0.0f) && (y > 1.0f) )
	goto ovrf;

x2 = x * x;
a = 1.0f - x2 - (y * y);
if( a == 0.0f )
	goto ovrf;

t = 0.5f * atan2f( 2.0f * x, a );
w = redupif( t );

t = y - 1.0f;
a = x2 + (t * t);
if( a == 0.0f )
	goto ovrf;

t = y + 1.0f;
a = (x2 + (t * t))/a;
w = w + (0.25f * logf (a)) * (1.0fi)  ;
return (w);

ovrf:
mtherr( "catanf", 3  );
w = MAXNUMF + MAXNUMF * (1.0fi)  ;
return (w);
}


 

























float __complex__ 
csinhf (float __complex__  z)
{
  float __complex__  w;
  float x, y;

  x = (__real__ ( z )) ;
  y = (__imag__ ( z )) ;
  w = sinhf (x) * cosf (y)  +  (coshf (x) * sinf (y)) * (1.0fi)  ;
  return (w);
}


 


























float __complex__ 
casinhf (float __complex__  z)
{
  float __complex__  w;

  w = -1.0f * (1.0fi)   * casinf (z * (1.0fi)  );
  return (w);
}


 


























float __complex__ 
ccoshf (float __complex__  z)
{
  float __complex__  w;
  float x, y;

  x = (__real__ ( z )) ;
  y = (__imag__ ( z )) ;
  w = coshf (x) * cosf (y)  +  (sinhf (x) * sinf (y)) * (1.0fi)  ;
  return (w);
}



 


























float __complex__ 
cacoshf (float __complex__  z)
{
  float __complex__  w;

  w = (1.0fi)   * cacosf (z);
  return (w);
}


 


























float __complex__ 
ctanhf (float __complex__  z)
{
  float __complex__  w;
  float x, y, d;

  x = (__real__ ( z )) ;
  y = (__imag__ ( z )) ;
  d = coshf (2.0f * x) + cosf (2.0f * y);
  w = sinhf (2.0f * x) / d  +  (sinf (2.0f * y) / d) * (1.0fi)  ;
  return (w);
}


 


























float __complex__ 
catanhf (float __complex__  z)
{
  float __complex__  w;

  w = -1.0f * (1.0fi)   * catanf (z * (1.0fi)  );
  return (w);
}

 




























float __complex__ 
cpowf (float __complex__  a, float __complex__  z)
{
  float __complex__  w;
  float x, y, r, theta, absa, arga;

  x = (__real__ ( z )) ;
  y = (__imag__ ( z )) ;
  absa = cabsf (a);
  if (absa == 0.0f)
    {
      return (0.0f + 0.0f * (1.0fi)  );
    }
  arga = (atan2f ((float) (__imag__ (  a  )) , (float) (__real__ (  a  )) )) ;
  r = powf (absa, x);
  theta = x * arga;
  if (y != 0.0f)
    {
      r = r * expf (-y * arga);
      theta = theta + y * logf (absa);
    }
  w = r * cosf (theta) + (r * sinf (theta)) * (1.0fi)  ;
  return (w);
}




More information about the Gcc-patches mailing list