From 70090654de737e465df6d9d4c8aaa531285e5c71 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Tue, 15 Mar 2016 17:03:10 +1100 Subject: [PATCH] cmd/compile/internal/gc: tidy plive.go Make boolean looking things boolean. Change-Id: I8d1c0a32b471412b25a72908c7da6458d7bbe65b Reviewed-on: https://go-review.googlesource.com/20723 Run-TryBot: Dave Cheney TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/gc/bv.go | 6 +++--- src/cmd/compile/internal/gc/plive.go | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/cmd/compile/internal/gc/bv.go b/src/cmd/compile/internal/gc/bv.go index 2c2d7eb71f..33c49ed69c 100644 --- a/src/cmd/compile/internal/gc/bv.go +++ b/src/cmd/compile/internal/gc/bv.go @@ -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) { diff --git a/src/cmd/compile/internal/gc/plive.go b/src/cmd/compile/internal/gc/plive.go index 089d4e252a..47987b4ce4 100644 --- a/src/cmd/compile/internal/gc/plive.go +++ b/src/cmd/compile/internal/gc/plive.go @@ -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 } -- 2.48.1