cmd/compile: introduce bytesizeToConst to cleanup switches in prove

Change-Id: I32b45d9632a8131911cb9bd6eff075eb8312ccfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/715043
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Jorropo 2025-10-26 15:53:51 +01:00
parent 9e25c2f6de
commit b8468d8c4e

View file

@ -2640,6 +2640,13 @@ var mostNegativeDividend = map[Op]int64{
OpDiv64: -1 << 63,
OpMod64: -1 << 63}
var bytesizeToConst = [...]Op{
8 / 8: OpConst8,
16 / 8: OpConst16,
32 / 8: OpConst32,
64 / 8: OpConst64,
}
// simplifyBlock simplifies some constant values in b and evaluates
// branches to non-uniquely dominated successors of b.
func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) {
@ -2702,18 +2709,7 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) {
if b.Func.pass.debug > 0 {
b.Func.Warnl(v.Pos, "Proved %v shifts to zero", v.Op)
}
switch bits {
case 64:
v.reset(OpConst64)
case 32:
v.reset(OpConst32)
case 16:
v.reset(OpConst16)
case 8:
v.reset(OpConst8)
default:
panic("unexpected integer size")
}
v.reset(bytesizeToConst[bits/8])
v.AuxInt = 0
break // Be sure not to fallthrough - this is no longer OpRsh.
}