cmd/compile: teach prove about more type conversion operations #26299
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
#26292 is about teaching the prove pass that, if
x byte
is <N,int(x)
is also <N. In particular, it helps when using byte variables as indices, since that seems to mean an implicit conversion to int. That was causing an unnecessary bounds check in anencoding/json
hot path.Here are some other cases which might be worthwhile to do. I don't know how useful they would be for software out there, like removing bounds checks in the standard library.
x uint32
is<10
,uint(x) < 10
(and same forint32/int
)x uint64
is<10
and we're on 64-bit,uint(x) < 10
x uint
is<10
,byte(x) < 10
x int
is non-negative and<10
,uint(x) < 10
/cc @aclements @rasky
The text was updated successfully, but these errors were encountered: