1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[dev.ssa] cmd/compile: fix complex128

complex128 was being treated as a complex64

Fixes math/cmplx.

Change-Id: I2996915b4cb6b94198d41cf08a30bd8531b9fec5
Reviewed-on: https://go-review.googlesource.com/14206
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Todd Neal 2015-09-02 21:11:32 -05:00
parent 5cb352edeb
commit 19285efaed
2 changed files with 31 additions and 2 deletions

View File

@ -1139,8 +1139,8 @@ func (s *state) expr(n *Node) *ssa.Value {
{
pt := Types[TFLOAT64]
return s.newValue2(ssa.OpComplexMake, n.Type,
s.constFloat32(pt, mpgetflt(r)),
s.constFloat32(pt, mpgetflt(i)))
s.constFloat64(pt, mpgetflt(r)),
s.constFloat64(pt, mpgetflt(i)))
}
default:
s.Fatalf("bad float size %d", n.Type.Size())

View File

@ -1467,42 +1467,69 @@ func expectCx64(s string, x, expected complex64) int {
}
func cx128sum_ssa(a, b complex128) complex128 {
switch { // prevent inlining
}
return a + b
}
func cx128diff_ssa(a, b complex128) complex128 {
switch { // prevent inlining
}
return a - b
}
func cx128prod_ssa(a, b complex128) complex128 {
switch { // prevent inlining
}
return a * b
}
func cx128quot_ssa(a, b complex128) complex128 {
switch { // prevent inlining
}
return a / b
}
func cx128neg_ssa(a complex128) complex128 {
switch { // prevent inlining
}
return -a
}
func cx128cnst_ssa(a complex128) complex128 {
switch { // prevent inlining
}
b := 2 + 3i
return a * b
}
func cx64sum_ssa(a, b complex64) complex64 {
switch { // prevent inlining
}
return a + b
}
func cx64diff_ssa(a, b complex64) complex64 {
switch { // prevent inlining
}
return a - b
}
func cx64prod_ssa(a, b complex64) complex64 {
switch { // prevent inlining
}
return a * b
}
func cx64quot_ssa(a, b complex64) complex64 {
switch { // prevent inlining
}
return a / b
}
func cx64neg_ssa(a complex64) complex64 {
switch { // prevent inlining
}
return -a
}
@ -1515,12 +1542,14 @@ func complexTest128() int {
prod := cx128prod_ssa(b, a)
quot := cx128quot_ssa(b, a)
neg := cx128neg_ssa(a)
cnst := cx128cnst_ssa(a)
fails += expectCx128("sum", sum, 4+8i)
fails += expectCx128("diff", diff, 2+4i)
fails += expectCx128("prod", prod, -9+12i)
fails += expectCx128("quot", quot, 3+0i)
fails += expectCx128("neg", neg, -1-2i)
fails += expectCx128("cnst", cnst, -4+7i)
return fails
}