Commit 2d21bf42 authored by Matthew Dempsky's avatar Matthew Dempsky

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 870cfe64
......@@ -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")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment