aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/cse.go
diff options
context:
space:
mode:
authorTodd Neal <todd@tneal.org>2015-09-04 06:33:56 -0500
committerTodd Neal <todd@tneal.org>2015-09-04 15:15:21 +0000
commit19447a66d663cf51f5c02c4d9d0c74894714067a (patch)
treedbb4dda231df0b30963baa89701be287d3577047 /src/cmd/compile/internal/ssa/cse.go
parent991036aef38cea57c2a7ef02220754d93799c489 (diff)
downloadgo-19447a66d663cf51f5c02c4d9d0c74894714067a.tar.gz
go-19447a66d663cf51f5c02c4d9d0c74894714067a.zip
[dev.ssa] cmd/compile: store floats in AuxInt
Store floats in AuxInt to reduce allocations. Change-Id: I101e6322530b4a0b2ea3591593ad022c992e8df8 Reviewed-on: https://go-review.googlesource.com/14320 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/cse.go')
-rw-r--r--src/cmd/compile/internal/ssa/cse.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/cmd/compile/internal/ssa/cse.go b/src/cmd/compile/internal/ssa/cse.go
index 6469ecd72b..836a7803ac 100644
--- a/src/cmd/compile/internal/ssa/cse.go
+++ b/src/cmd/compile/internal/ssa/cse.go
@@ -4,10 +4,7 @@
package ssa
-import (
- "math"
- "sort"
-)
+import "sort"
// cse does common-subexpression elimination on the Function.
// Values are just relinked, nothing is deleted. A subsequent deadcode
@@ -55,18 +52,11 @@ func cse(f *Func) {
arg1op = v.Args[1].Op
}
- aux := v.Aux
- auxInt := v.AuxInt
- // -0 == 0, but aren't equivalent values so we use
- // Float64bits to distinguish
- if f, ok := aux.(float64); ok {
- aux = nil
- if auxInt != 0 {
- v.Fatalf("float would clobber v.auxInt")
- }
- auxInt = int64(math.Float64bits(f))
- }
- k := key{v.Op, v.Type.String(), aux, auxInt, len(v.Args), bid, arg0op, arg1op}
+ // This assumes that floats are stored in AuxInt
+ // instead of Aux. If not, then we need to use the
+ // float bits as part of the key, otherwise since 0.0 == -0.0
+ // this would incorrectly treat 0.0 and -0.0 as identical values
+ k := key{v.Op, v.Type.String(), v.Aux, v.AuxInt, len(v.Args), bid, arg0op, arg1op}
m[k] = append(m[k], v)
}
}