The compiler cannot currently determine that the accesses to len8tab
are within bounds. Cast to uint8 to avoid unnecessary bounds checks.
Fixes #76166
Change-Id: I1fd930bba2b20d3998252c476308642e08ce00b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/718040
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
x >>= 8
n += 8
}
- return n + int(len8tab[x])
+ return n + int(len8tab[uint8(x)])
}
// --- OnesCount ---
x >>= 8
n = 8
}
- return n + int(len8tab[x])
+ return n + int(len8tab[uint8(x)])
}
// Len32 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
x >>= 8
n += 8
}
- return n + int(len8tab[x])
+ return n + int(len8tab[uint8(x)])
}
// Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
x >>= 8
n += 8
}
- return n + int(len8tab[x])
+ return n + int(len8tab[uint8(x)])
}
// --- Add with carry ---