I am using Julia 1.12.4. It seems that @fastmath breaks efficient integer powers for Float32.
Simple code:
This is good (Float64):
julia> @code_llvm debuginfo=:none f(1.0)
; Function Signature: f(Float64)
define double @julia_f_3688(double %"x::Float64") #0 {
top:
%0 = fmul double %"x::Float64", %"x::Float64"
ret double %0
}
This is bad (Float32):
julia> @code_llvm debuginfo=:none f(1.0f0)
; Function Signature: f(Float32)
define float @julia_f_3715(float %"x::Float32") #0 {
top:
%0 = fpext float %"x::Float32" to double
%1 = call double @"j_#power_by_squaring#401_3717"(double %0, i64 signext 2)
%2 = fptrunc double %1 to float
ret float %2
}
Not only is power_by_squaring not inlined, it even converts to and from Float64!
See also #59804. I assume this fixed things for Float64 but not for Float32.
I am using Julia 1.12.4. It seems that
@fastmathbreaks efficient integer powers for Float32.Simple code:
This is good (Float64):
This is bad (Float32):
Not only is
power_by_squaringnot inlined, it even converts to and fromFloat64!See also #59804. I assume this fixed things for Float64 but not for Float32.