diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-12-01 18:59:18 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-12-03 08:21:02 -0800 |
commit | cd34d5f2c40f3c65407f4b0bee0b49fc84e4a4ab (patch) | |
tree | 843df1c1321bbc66e1bee850fa8513c54dd25dc8 /libgo/runtime | |
parent | 65af6bc9f87bc6b329fb7a16e3f736dd0a042bf5 (diff) | |
download | gcc-cd34d5f2c40f3c65407f4b0bee0b49fc84e4a4ab.zip gcc-cd34d5f2c40f3c65407f4b0bee0b49fc84e4a4ab.tar.gz gcc-cd34d5f2c40f3c65407f4b0bee0b49fc84e4a4ab.tar.bz2 |
compiler: defer to middle-end for complex division
Go used to use slightly different semantics than C99 for complex division,
so we used runtime routines to handle the different. The gc compiler
has changes its behavior to match C99, so changes ours as well.
For golang/go#14644
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/274213
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/go-cdiv.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/libgo/runtime/go-cdiv.c b/libgo/runtime/go-cdiv.c deleted file mode 100644 index 0355e26..0000000 --- a/libgo/runtime/go-cdiv.c +++ /dev/null @@ -1,49 +0,0 @@ -/* go-cdiv.c -- complex division routines - - Copyright 2013 The Go Authors. All rights reserved. - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file. */ - -#include <complex.h> -#include <math.h> - -/* Calls to these functions are generated by the Go frontend for - division of complex64 or complex128. We use these because Go's - complex division expects slightly different results from the GCC - default. When dividing NaN+1.0i / 0+0i, Go expects NaN+NaNi but - GCC generates NaN+Infi. NaN+Infi seems wrong seems the rules of - C99 Annex G specify that if either side of a complex number is Inf, - the the whole number is Inf, but an operation involving NaN ought - to result in NaN, not Inf. */ - -complex float -__go_complex64_div (complex float a, complex float b) -{ - if (__builtin_expect (b == 0, 0)) - { - if (!isinf (crealf (a)) - && !isinf (cimagf (a)) - && (isnan (crealf (a)) || isnan (cimagf (a)))) - { - /* Pass "1" to nanf to match math/bits.go. */ - return nanf("1") + nanf("1")*I; - } - } - return a / b; -} - -complex double -__go_complex128_div (complex double a, complex double b) -{ - if (__builtin_expect (b == 0, 0)) - { - if (!isinf (creal (a)) - && !isinf (cimag (a)) - && (isnan (creal (a)) || isnan (cimag (a)))) - { - /* Pass "1" to nan to match math/bits.go. */ - return nan("1") + nan("1")*I; - } - } - return a / b; -} |