]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use isGenericIntConst() in prove
authorJakub Ciolek <jakub@ciolek.dev>
Tue, 14 Jan 2025 20:29:50 +0000 (21:29 +0100)
committerKeith Randall <khr@golang.org>
Tue, 4 Feb 2025 17:39:40 +0000 (09:39 -0800)
Use the existing Value method to make it a bit shorter.

Change-Id: I47c4328b5241ab48b3490a04a3d93d4428f7b88c
Reviewed-on: https://go-review.googlesource.com/c/go/+/642735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ssa/prove.go

index c3948dc9b1d370b71620d3b1239f7ef152cc6624..8d0bb73d4c0c08ea99b4b94dcacbaf10e5f49b4b 100644 (file)
@@ -1362,11 +1362,11 @@ func prove(f *Func) {
                        start, end = end, start
                }
 
-               if !(start.Op == OpConst8 || start.Op == OpConst16 || start.Op == OpConst32 || start.Op == OpConst64) {
+               if !start.isGenericIntConst() {
                        // if start is not a constant we would be winning nothing from inverting the loop
                        continue
                }
-               if end.Op == OpConst8 || end.Op == OpConst16 || end.Op == OpConst32 || end.Op == OpConst64 {
+               if end.isGenericIntConst() {
                        // TODO: if both start and end are constants we should rewrite such that the comparison
                        // is against zero and nxt is ++ or -- operation
                        // That means: