]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: tidy plive.go
authorDave Cheney <dave@cheney.net>
Tue, 15 Mar 2016 06:03:10 +0000 (17:03 +1100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 15 Mar 2016 15:27:21 +0000 (15:27 +0000)
Make boolean looking things boolean.

Change-Id: I8d1c0a32b471412b25a72908c7da6458d7bbe65b
Reviewed-on: https://go-review.googlesource.com/20723
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/bv.go
src/cmd/compile/internal/gc/plive.go

index 2c2d7eb71f65ac4e128e5f25e01a1f9b1df98cc2..33c49ed69c3246596bfb61a8955d8eb9d4242190 100644 (file)
@@ -63,16 +63,16 @@ func bvandnot(dst Bvec, src1 Bvec, src2 Bvec) {
        }
 }
 
-func bvcmp(bv1 Bvec, bv2 Bvec) int {
+func bveq(bv1 Bvec, bv2 Bvec) bool {
        if bv1.n != bv2.n {
                Fatalf("bvequal: lengths %d and %d are not equal", bv1.n, bv2.n)
        }
        for i, x := range bv1.b {
                if x != bv2.b[i] {
-                       return 1
+                       return false
                }
        }
-       return 0
+       return true
 }
 
 func bvcopy(dst Bvec, src Bvec) {
index 089d4e252ad9909fcca78fc559694d2bf140607b..47987b4ce48d0ec247f44b6491cbdec75aef85d7 100644 (file)
@@ -1092,9 +1092,8 @@ func livenesssolve(lv *Liveness) {
                bvcopy(bb.avarinitany, bb.avarinit)
        }
 
-       change := int32(1)
-       for change != 0 {
-               change = 0
+       for change := true; change; {
+               change = false
                for _, bb := range lv.cfg {
                        bvresetall(any)
                        bvresetall(all)
@@ -1112,13 +1111,13 @@ func livenesssolve(lv *Liveness) {
                        bvandnot(all, all, bb.varkill)
                        bvor(any, any, bb.avarinit)
                        bvor(all, all, bb.avarinit)
-                       if bvcmp(any, bb.avarinitany) != 0 {
-                               change = 1
+                       if !bveq(any, bb.avarinitany) {
+                               change = true
                                bvcopy(bb.avarinitany, any)
                        }
 
-                       if bvcmp(all, bb.avarinitall) != 0 {
-                               change = 1
+                       if !bveq(all, bb.avarinitall) {
+                               change = true
                                bvcopy(bb.avarinitall, all)
                        }
                }
@@ -1127,10 +1126,9 @@ func livenesssolve(lv *Liveness) {
        // Iterate through the blocks in reverse round-robin fashion. A work
        // queue might be slightly faster. As is, the number of iterations is
        // so low that it hardly seems to be worth the complexity.
-       change = 1
 
-       for change != 0 {
-               change = 0
+       for change := true; change; {
+               change = false
 
                // Walk blocks in the general direction of propagation. This
                // improves convergence.
@@ -1146,8 +1144,8 @@ func livenesssolve(lv *Liveness) {
                                bvor(newliveout, newliveout, succ.livein)
                        }
 
-                       if bvcmp(bb.liveout, newliveout) != 0 {
-                               change = 1
+                       if !bveq(bb.liveout, newliveout) {
+                               change = true
                                bvcopy(bb.liveout, newliveout)
                        }
 
@@ -1506,7 +1504,7 @@ func livenesscompact(lv *Liveness) {
                        }
                        jlocal := lv.livepointers[j]
                        jarg := lv.argslivepointers[j]
-                       if bvcmp(local, jlocal) == 0 && bvcmp(arg, jarg) == 0 {
+                       if bveq(local, jlocal) && bveq(arg, jarg) {
                                remap[i] = j
                                goto Next
                        }