Le 20/01/2017 à 20:01, Matt Wette a écrit :

On Jan 19, 2017, at 7:01 PM, Matt Wette <matt.we...@gmail.com <mailto:matt.we...@gmail.com>> wrote:


On Jan 18, 2017, at 6:26 PM, Andy Wingo <wi...@pobox.com <mailto:wi...@pobox.com>> wrote:

We are pleased to announce GNU Guile release 2.1.6.

Guile 2.1.6 is the sixth pre-release in what will eventually become the
2.2 release series.  We encourage you to test this release and provide
feedback to guile-devel@gnu.org <mailto:guile-devel@gnu.org>.

Saw this one last round.  Mac OS, now gcc-6.3.0:

;;; ("#i1@-0" 1.0 -0.0)
FAIL: numbers.test: string->number: valid complex number strings

I am going to see if I can generate the assembly.

Short story: scm_c_make_polar is broken for the Mac. Guile needs to decide if it want to use __sincos() on Mac, or suppress optimization, or ...

I was able to get the above to work (guile-2.1.5) by using
 SCM
+#ifdef __APPLE__
+__attribute__((optimize("O0")))
+#endif
 scm_c_make_polar (double mag, double ang)


In scm_c_make_polar, “gcc -O2” turns sin(), cos() into cexp(), since cexp(i*x) = cos(x) + i*sin(x):

gcc -O0 =>
LM4339:
movq-32(%rbp), %rax
movd%rax, %xmm0
call_sin
movd%xmm0, %rax
movq%rax, -8(%rbp)
LM4340:
movq-32(%rbp), %rax
movd%rax, %xmm0
call_cos
movd%xmm0, %rax
movq%rax, -16(%rbp)

gcc -O2 =>
pxor%xmm0, %xmm0
LVL2703:
call_cexp

I wrote a little C program to show that cexp() does not preserve the zero-signed-ness:

 cos,sin: +1.000000 -0.000000
__sincos: +1.000000 -0.000000
    cexp: +1.000000 +0.000000

The scm_c_make_polar will use sincos() if available, but macOS does not have sincos(), it has __sincos().

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

extern double z, p, n;

int main() {
  double complex c;
  double d, sine, cosine;

  d = z*n;
  printf(" cos,sin: %+f %+f\n", cos(d), sin(d));
  __sincos(d, &sine, &cosine);
  printf("__sincos: %+f %+f\n", cosine, sine);
  c = cexp(CMPLX(0.0, d));
  printf("    cexp: %+f %+f\n", creal(c), cimag(c));
}

double z = 0.0, p = +1.0, n = -1.0;

Incidentally, the above program will not compile on my machine w/ gcc-6.3.0. “gcc -std=c11” or “gcc -std=c99” will not recognize the standard macro CMPLX().



wow!

Reply via email to