mirror of
https://github.com/golang/go
synced 2024-11-17 19:54:45 -07:00
cmd/compile: cleanup OREAL/OIMAG constant folding
Based on suggestion from gri@ on golang.org/cl/166980. Passes toolstash-check. Change-Id: I79b66bb09b5635f3a9daecaa5d605b661a0ab108 Reviewed-on: https://go-review.googlesource.com/c/go/+/167501 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
870cfe6484
commit
2d21bf4252
@ -676,17 +676,17 @@ func evconst(n *Node) {
|
||||
case OREAL, OIMAG:
|
||||
if nl.Op == OLITERAL {
|
||||
var re, im *Mpflt
|
||||
switch consttype(nl) {
|
||||
case CTINT, CTRUNE:
|
||||
switch u := nl.Val().U.(type) {
|
||||
case *Mpint:
|
||||
re = newMpflt()
|
||||
re.SetInt(nl.Val().U.(*Mpint))
|
||||
re.SetInt(u)
|
||||
// im = 0
|
||||
case CTFLT:
|
||||
re = nl.Val().U.(*Mpflt)
|
||||
case *Mpflt:
|
||||
re = u
|
||||
// im = 0
|
||||
case CTCPLX:
|
||||
re = &nl.Val().U.(*Mpcplx).Real
|
||||
im = &nl.Val().U.(*Mpcplx).Imag
|
||||
case *Mpcplx:
|
||||
re = &u.Real
|
||||
im = &u.Imag
|
||||
default:
|
||||
Fatalf("impossible")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user