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

[dev.ssa] cmd/compile: minor CSE cleanup

Remove unnecessary local var split.

Change-Id: I907ef682b5fd9b3a67771edd1fe90c558f8937ea
Reviewed-on: https://go-review.googlesource.com/14523
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2015-09-11 10:28:33 -07:00
parent cea441427e
commit 9552295833

View File

@ -92,20 +92,18 @@ func cse(f *Func) {
// all values in this equiv class that are not equivalent to v get moved // all values in this equiv class that are not equivalent to v get moved
// into another equiv class. // into another equiv class.
// To avoid allocating while building that equivalence class, // To avoid allocating while building that equivalence class,
// move the values equivalent to v to the beginning of e, // move the values equivalent to v to the beginning of e
// other values to the end of e, and track where the split is. // and other values to the end of e.
allvals := e allvals := e
split := len(e)
eqloop: eqloop:
for j := 1; j < len(e); { for j := 1; j < len(e); {
w := e[j] w := e[j]
for i := 0; i < len(v.Args); i++ { for i := 0; i < len(v.Args); i++ {
if valueEqClass[v.Args[i].ID] != valueEqClass[w.Args[i].ID] || !v.Type.Equal(w.Type) { if valueEqClass[v.Args[i].ID] != valueEqClass[w.Args[i].ID] || !v.Type.Equal(w.Type) {
// w is not equivalent to v. // w is not equivalent to v.
// move it to the end, shrink e, and move the split. // move it to the end and shrink e.
e[j], e[len(e)-1] = e[len(e)-1], e[j] e[j], e[len(e)-1] = e[len(e)-1], e[j]
e = e[:len(e)-1] e = e[:len(e)-1]
split--
valueEqClass[w.ID] = len(partition) valueEqClass[w.ID] = len(partition)
changed = true changed = true
continue eqloop continue eqloop
@ -115,8 +113,8 @@ func cse(f *Func) {
j++ j++
} }
partition[i] = e partition[i] = e
if split < len(allvals) { if len(e) < len(allvals) {
partition = append(partition, allvals[split:]) partition = append(partition, allvals[len(e):])
} }
} }