diff options
author | David Chase <drchase@google.com> | 2016-03-21 11:32:04 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2016-04-13 15:59:42 +0000 |
commit | 6b85a45edc94786c7669823ee47a6ce1156d6a9a (patch) | |
tree | 19a3f32cee6a26073cd1f4f6beeb053599e40663 /src/cmd/compile/internal/ssa/sparsemap.go | |
parent | c4807d4cc759025854e354fee99ac20d125f0d79 (diff) | |
download | go-6b85a45edc94786c7669823ee47a6ce1156d6a9a.tar.gz go-6b85a45edc94786c7669823ee47a6ce1156d6a9a.zip |
cmd/compile: move spills to loop exits when easy.
For call-free inner loops.
Revised statistics:
85 inner loop spills sunk
341 inner loop spills remaining
1162 inner loop spills that were candidates for sinking
ended up completely register allocated
119 inner loop spills could have been sunk were used in
"shuffling" at the bottom of the loop.
1 inner loop spill not sunk because the register assigned
changed between def and exit,
Understanding how to make an inner loop definition not be
a candidate for from-memory shuffling (to force the shuffle
code to choose some other value) should pick up some of the
119 other spills disqualified for this reason.
Modified the stats printing based on feedback from Austin.
Change-Id: If3fb9b5d5a028f42ccc36c4e3d9e0da39db5ca60
Reviewed-on: https://go-review.googlesource.com/21037
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/sparsemap.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/sparsemap.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/sparsemap.go b/src/cmd/compile/internal/ssa/sparsemap.go index 6c0043b230..0211a70f09 100644 --- a/src/cmd/compile/internal/ssa/sparsemap.go +++ b/src/cmd/compile/internal/ssa/sparsemap.go @@ -32,6 +32,8 @@ func (s *sparseMap) contains(k ID) bool { return i < len(s.dense) && s.dense[i].key == k } +// get returns the value for key k, or -1 if k does +// not appear in the map. func (s *sparseMap) get(k ID) int32 { i := s.sparse[k] if i < len(s.dense) && s.dense[i].key == k { @@ -50,6 +52,20 @@ func (s *sparseMap) set(k ID, v int32) { s.sparse[k] = len(s.dense) - 1 } +// setBit sets the v'th bit of k's value, where 0 <= v < 32 +func (s *sparseMap) setBit(k ID, v uint) { + if v >= 32 { + panic("bit index too large.") + } + i := s.sparse[k] + if i < len(s.dense) && s.dense[i].key == k { + s.dense[i].val |= 1 << v + return + } + s.dense = append(s.dense, sparseEntry{k, 1 << v}) + s.sparse[k] = len(s.dense) - 1 +} + func (s *sparseMap) remove(k ID) { i := s.sparse[k] if i < len(s.dense) && s.dense[i].key == k { |