math: Compute `x^1` and `x^2` inline for `Float64` and a runtime exponent (#65413)
^(::Float64, ::Integer)` called the out-of-line `pow_int` for every nonzero
exponent. Exponents 1 and 2 now return `x` and `x * x` directly, as
`literal_pow` does for literal exponents. Callers whose exponent only becomes
a constant after inlining then make no call at all, such as a dual number's
`^(a::Dual, n::Integer) = Dual(a.v^n, (n * a.v^(n - 1)) .* a.p)` used as
`x^2`.
On the `apps/dual_gradient` runtime benchmark (Apple M-series, patched into
a nightly) this is 342.6 → 58.3 instructions and 38.9 → 12.4 cycles per
operation; 1.10 takes 303.7 instructions and 39.2 cycles.
A runtime exponent of 2 could differ from `x * x` in the last bit when
`x^2` is below about `2.0^-969`, where the error term of the compensated
squaring is subnormal. It now gives the correctly rounded `x * x`, the same
as a literal `x^2`.