3 ms·
Go in practice doesn't actually use the code cited. Most of the math/bits package is recognized by the compiler and intrinsified down into 1 or a few CPU instr
by bradfitz 6y ago
Go in practice doesn't actually use the code cited.
Most of the math/bits package is recognized by the compiler and intrinsified down into 1 or a few CPU instructions (not function calls) on almost all architectures.
In a git checkout of Go, look at e.g. `git grep Div64 src/cmd/compile`.
- smikhanov 6y agoOut of interest, when would that code be used? When compiling for an architecture that doesn’t have intrinsics defined?
- pansa2 6y agoThanks, I missed that the Go code in the article was only performing a "128-bit / 64-bit" division. However, based on this comment [0], it looks like Go does use Knuth's algorithm when dividing arbitrary-precision integers. [0] https://github.com/golang/go/blob/2e94401277128f9e08e3319903d1b78c09c4ab98/src/math/big/nat.go#L696 https://github.com/golang/go/blob/2e94401277128f9e08e3319903...