Skip to content

Commit

Permalink
cmd/compile: upgrade prove pass to know results of math/bits ops are …
Browse files Browse the repository at this point in the history
…nonnegative

Fixes #51963

Change-Id: Ib9e0521222e6fc41e787f3150b254e058a19addc
Reviewed-on: https://go-review.googlesource.com/c/go/+/396036
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
  • Loading branch information
randall77 committed Mar 27, 2022
1 parent 7d3b64a commit 3bd8c78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cmd/compile/internal/ssa/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ func prove(f *Func) {
}
lensVars[b] = append(lensVars[b], v)
}
case OpCtz64, OpCtz32, OpCtz16, OpCtz8, OpBitLen64, OpBitLen32, OpBitLen16, OpBitLen8:
ft.update(b, v, ft.zero, signed, gt|eq)
// TODO: we could also do <= 64/32/16/8, if that helped.
}
}
}
Expand Down Expand Up @@ -1372,7 +1375,9 @@ func isNonNegative(v *Value) bool {
case OpStringLen, OpSliceLen, OpSliceCap,
OpZeroExt8to64, OpZeroExt16to64, OpZeroExt32to64,
OpZeroExt8to32, OpZeroExt16to32, OpZeroExt8to16,
OpCtz64, OpCtz32, OpCtz16, OpCtz8:
OpCtz64, OpCtz32, OpCtz16, OpCtz8,
OpCtz64NonZero, OpCtz32NonZero, OpCtz16NonZero, OpCtz8NonZero,
OpBitLen64, OpBitLen32, OpBitLen16, OpBitLen8:
return true

case OpRsh64Ux64, OpRsh32Ux64:
Expand Down

0 comments on commit 3bd8c78

Please sign in to comment.