This is the standard way to check whether a value is 32 bit:
func is32bit(x int64) bool {
return x == int64(int32(x))
}
On amd64, this compiles to a MOVLQSX and a CMPQ. However, it could compile to just a TESTL of the top half of the register.
Is there a reason that we don't have any optimizations like this, other than that no one has bothered to write any yet?
This is the standard way to check whether a value is 32 bit:
On amd64, this compiles to a MOVLQSX and a CMPQ. However, it could compile to just a TESTL of the top half of the register.
Is there a reason that we don't have any optimizations like this, other than that no one has bothered to write any yet?