]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: simplify zcse
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Apr 2020 04:34:48 +0000 (21:34 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Apr 2020 14:59:41 +0000 (14:59 +0000)
Minor refactoring.

Passes toolstash-check.

Change-Id: I91e981bf369d4b719163107644fa58f583356c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/229598
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/ssa/zcse.go

index 44688d95737f1ac577f097a5a0a2818b9758175c..ec38b7d1ba4ae2abd55dfa045b3283cd008b2642 100644 (file)
@@ -15,9 +15,8 @@ func zcse(f *Func) {
        vals := make(map[vkey]*Value)
 
        for _, b := range f.Blocks {
-               for i := 0; i < len(b.Values); {
+               for i := 0; i < len(b.Values); i++ {
                        v := b.Values[i]
-                       next := true
                        if opcodeTable[v.Op].argLen == 0 {
                                key := vkey{v.Op, keyFor(v), v.Aux, v.Type}
                                if vals[key] == nil {
@@ -33,14 +32,10 @@ func zcse(f *Func) {
                                                b.Values[last] = nil
                                                b.Values = b.Values[:last]
 
-                                               // process b.Values[i] again
-                                               next = false
+                                               i-- // process b.Values[i] again
                                        }
                                }
                        }
-                       if next {
-                               i++
-                       }
                }
        }