
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (/ 1.0 (sin normAngle))))
(+
(* (* (sin (* (- 1.0 u) normAngle)) t_0) n0_i)
(* (* (sin (* u normAngle)) t_0) n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float t_0 = 1.0f / sinf(normAngle);
return ((sinf(((1.0f - u) * normAngle)) * t_0) * n0_i) + ((sinf((u * normAngle)) * t_0) * n1_i);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: t_0
t_0 = 1.0e0 / sin(normangle)
code = ((sin(((1.0e0 - u) * normangle)) * t_0) * n0_i) + ((sin((u * normangle)) * t_0) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) t_0 = Float32(Float32(1.0) / sin(normAngle)) return Float32(Float32(Float32(sin(Float32(Float32(Float32(1.0) - u) * normAngle)) * t_0) * n0_i) + Float32(Float32(sin(Float32(u * normAngle)) * t_0) * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) t_0 = single(1.0) / sin(normAngle); tmp = ((sin(((single(1.0) - u) * normAngle)) * t_0) * n0_i) + ((sin((u * normAngle)) * t_0) * n1_i); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sin normAngle}\\
\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i
\end{array}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (/ 1.0 (sin normAngle))))
(+
(* (* (sin (* (- 1.0 u) normAngle)) t_0) n0_i)
(* (* (sin (* u normAngle)) t_0) n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float t_0 = 1.0f / sinf(normAngle);
return ((sinf(((1.0f - u) * normAngle)) * t_0) * n0_i) + ((sinf((u * normAngle)) * t_0) * n1_i);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: t_0
t_0 = 1.0e0 / sin(normangle)
code = ((sin(((1.0e0 - u) * normangle)) * t_0) * n0_i) + ((sin((u * normangle)) * t_0) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) t_0 = Float32(Float32(1.0) / sin(normAngle)) return Float32(Float32(Float32(sin(Float32(Float32(Float32(1.0) - u) * normAngle)) * t_0) * n0_i) + Float32(Float32(sin(Float32(u * normAngle)) * t_0) * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) t_0 = single(1.0) / sin(normAngle); tmp = ((sin(((single(1.0) - u) * normAngle)) * t_0) * n0_i) + ((sin((u * normAngle)) * t_0) * n1_i); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sin normAngle}\\
\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i
\end{array}
\end{array}
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(fma
(+
(fma -1.0 n0_i n1_i)
(fma
(fma
(* -0.5 n0_i)
(* normAngle normAngle)
(*
(* (* normAngle normAngle) -0.16666666666666666)
(* (fma -1.0 n0_i n1_i) u)))
u
(*
(fma 0.5 n0_i (* 0.16666666666666666 (fma -1.0 n0_i n1_i)))
(* normAngle normAngle))))
u
n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf(-1.0f, n0_i, n1_i) + fmaf(fmaf((-0.5f * n0_i), (normAngle * normAngle), (((normAngle * normAngle) * -0.16666666666666666f) * (fmaf(-1.0f, n0_i, n1_i) * u))), u, (fmaf(0.5f, n0_i, (0.16666666666666666f * fmaf(-1.0f, n0_i, n1_i))) * (normAngle * normAngle)))), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(Float32(-1.0), n0_i, n1_i) + fma(fma(Float32(Float32(-0.5) * n0_i), Float32(normAngle * normAngle), Float32(Float32(Float32(normAngle * normAngle) * Float32(-0.16666666666666666)) * Float32(fma(Float32(-1.0), n0_i, n1_i) * u))), u, Float32(fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * fma(Float32(-1.0), n0_i, n1_i))) * Float32(normAngle * normAngle)))), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(-1, n0\_i, n1\_i\right) + \mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot n0\_i, normAngle \cdot normAngle, \left(\left(normAngle \cdot normAngle\right) \cdot -0.16666666666666666\right) \cdot \left(\mathsf{fma}\left(-1, n0\_i, n1\_i\right) \cdot u\right)\right), u, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \mathsf{fma}\left(-1, n0\_i, n1\_i\right)\right) \cdot \left(normAngle \cdot normAngle\right)\right), u, n0\_i\right)
\end{array}
Initial program 97.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.8%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.2%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(fma
(+
(fma -1.0 n0_i n1_i)
(fma
(* -0.16666666666666666 (* n1_i (* (* normAngle normAngle) u)))
u
(*
(fma 0.5 n0_i (* 0.16666666666666666 (fma -1.0 n0_i n1_i)))
(* normAngle normAngle))))
u
n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf(-1.0f, n0_i, n1_i) + fmaf((-0.16666666666666666f * (n1_i * ((normAngle * normAngle) * u))), u, (fmaf(0.5f, n0_i, (0.16666666666666666f * fmaf(-1.0f, n0_i, n1_i))) * (normAngle * normAngle)))), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(Float32(-1.0), n0_i, n1_i) + fma(Float32(Float32(-0.16666666666666666) * Float32(n1_i * Float32(Float32(normAngle * normAngle) * u))), u, Float32(fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * fma(Float32(-1.0), n0_i, n1_i))) * Float32(normAngle * normAngle)))), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(-1, n0\_i, n1\_i\right) + \mathsf{fma}\left(-0.16666666666666666 \cdot \left(n1\_i \cdot \left(\left(normAngle \cdot normAngle\right) \cdot u\right)\right), u, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \mathsf{fma}\left(-1, n0\_i, n1\_i\right)\right) \cdot \left(normAngle \cdot normAngle\right)\right), u, n0\_i\right)
\end{array}
Initial program 97.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.8%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.2%
Taylor expanded in n0_i around 0
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f3299.1
Applied rewrites99.1%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(fma
(+
(fma -1.0 n0_i n1_i)
(fma
(* -0.16666666666666666 (* n1_i (* (* normAngle normAngle) u)))
u
(* (* 0.16666666666666666 n1_i) (* normAngle normAngle))))
u
n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf(-1.0f, n0_i, n1_i) + fmaf((-0.16666666666666666f * (n1_i * ((normAngle * normAngle) * u))), u, ((0.16666666666666666f * n1_i) * (normAngle * normAngle)))), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(Float32(-1.0), n0_i, n1_i) + fma(Float32(Float32(-0.16666666666666666) * Float32(n1_i * Float32(Float32(normAngle * normAngle) * u))), u, Float32(Float32(Float32(0.16666666666666666) * n1_i) * Float32(normAngle * normAngle)))), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(-1, n0\_i, n1\_i\right) + \mathsf{fma}\left(-0.16666666666666666 \cdot \left(n1\_i \cdot \left(\left(normAngle \cdot normAngle\right) \cdot u\right)\right), u, \left(0.16666666666666666 \cdot n1\_i\right) \cdot \left(normAngle \cdot normAngle\right)\right), u, n0\_i\right)
\end{array}
Initial program 97.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.8%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.2%
Taylor expanded in n0_i around 0
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f3299.1
Applied rewrites99.1%
Taylor expanded in n0_i around 0
lower-*.f3298.9
Applied rewrites98.9%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(fma
(+
(fma
(fma 0.5 n0_i (* 0.16666666666666666 (fma -1.0 n0_i n1_i)))
(* normAngle normAngle)
(- n0_i))
n1_i)
u
n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf(fmaf(0.5f, n0_i, (0.16666666666666666f * fmaf(-1.0f, n0_i, n1_i))), (normAngle * normAngle), -n0_i) + n1_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * fma(Float32(-1.0), n0_i, n1_i))), Float32(normAngle * normAngle), Float32(-n0_i)) + n1_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \mathsf{fma}\left(-1, n0\_i, n1\_i\right)\right), normAngle \cdot normAngle, -n0\_i\right) + n1\_i, u, n0\_i\right)
\end{array}
Initial program 97.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.8%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.0%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (fma (+ (fma (* 0.16666666666666666 n1_i) (* normAngle normAngle) (- n0_i)) n1_i) u n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf((0.16666666666666666f * n1_i), (normAngle * normAngle), -n0_i) + n1_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(Float32(Float32(0.16666666666666666) * n1_i), Float32(normAngle * normAngle), Float32(-n0_i)) + n1_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot n1\_i, normAngle \cdot normAngle, -n0\_i\right) + n1\_i, u, n0\_i\right)
\end{array}
Initial program 97.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.8%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.0%
Taylor expanded in n0_i around 0
lower-*.f3298.8
Applied rewrites98.8%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (* n0_i (- 1.0 u))))
(if (<= n0_i -2.50000003337858e-11)
t_0
(if (<= n0_i 7.999999968033578e-12) (+ n0_i (* u n1_i)) t_0))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float t_0 = n0_i * (1.0f - u);
float tmp;
if (n0_i <= -2.50000003337858e-11f) {
tmp = t_0;
} else if (n0_i <= 7.999999968033578e-12f) {
tmp = n0_i + (u * n1_i);
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: t_0
real(4) :: tmp
t_0 = n0_i * (1.0e0 - u)
if (n0_i <= (-2.50000003337858e-11)) then
tmp = t_0
else if (n0_i <= 7.999999968033578e-12) then
tmp = n0_i + (u * n1_i)
else
tmp = t_0
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) t_0 = Float32(n0_i * Float32(Float32(1.0) - u)) tmp = Float32(0.0) if (n0_i <= Float32(-2.50000003337858e-11)) tmp = t_0; elseif (n0_i <= Float32(7.999999968033578e-12)) tmp = Float32(n0_i + Float32(u * n1_i)); else tmp = t_0; end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) t_0 = n0_i * (single(1.0) - u); tmp = single(0.0); if (n0_i <= single(-2.50000003337858e-11)) tmp = t_0; elseif (n0_i <= single(7.999999968033578e-12)) tmp = n0_i + (u * n1_i); else tmp = t_0; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n0\_i \cdot \left(1 - u\right)\\
\mathbf{if}\;n0\_i \leq -2.50000003337858 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n0\_i \leq 7.999999968033578 \cdot 10^{-12}:\\
\;\;\;\;n0\_i + u \cdot n1\_i\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n0_i < -2.50000003e-11 or 7.99999997e-12 < n0_i Initial program 98.4%
Taylor expanded in n0_i around inf
associate-/l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-/.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-sin.f32N/A
lift-sin.f3289.3
Applied rewrites89.3%
Taylor expanded in normAngle around 0
lift--.f3289.0
Applied rewrites89.0%
if -2.50000003e-11 < n0_i < 7.99999997e-12Initial program 96.7%
Taylor expanded in normAngle around 0
Applied rewrites97.3%
Taylor expanded in u around 0
Applied rewrites85.2%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (* n0_i (- 1.0 u))))
(if (<= n0_i -2.499999999549897e-24)
t_0
(if (<= n0_i 4.999999841327613e-22) (* u n1_i) t_0))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float t_0 = n0_i * (1.0f - u);
float tmp;
if (n0_i <= -2.499999999549897e-24f) {
tmp = t_0;
} else if (n0_i <= 4.999999841327613e-22f) {
tmp = u * n1_i;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: t_0
real(4) :: tmp
t_0 = n0_i * (1.0e0 - u)
if (n0_i <= (-2.499999999549897e-24)) then
tmp = t_0
else if (n0_i <= 4.999999841327613e-22) then
tmp = u * n1_i
else
tmp = t_0
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) t_0 = Float32(n0_i * Float32(Float32(1.0) - u)) tmp = Float32(0.0) if (n0_i <= Float32(-2.499999999549897e-24)) tmp = t_0; elseif (n0_i <= Float32(4.999999841327613e-22)) tmp = Float32(u * n1_i); else tmp = t_0; end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) t_0 = n0_i * (single(1.0) - u); tmp = single(0.0); if (n0_i <= single(-2.499999999549897e-24)) tmp = t_0; elseif (n0_i <= single(4.999999841327613e-22)) tmp = u * n1_i; else tmp = t_0; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n0\_i \cdot \left(1 - u\right)\\
\mathbf{if}\;n0\_i \leq -2.499999999549897 \cdot 10^{-24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n0\_i \leq 4.999999841327613 \cdot 10^{-22}:\\
\;\;\;\;u \cdot n1\_i\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n0_i < -2.5e-24 or 4.9999998e-22 < n0_i Initial program 97.8%
Taylor expanded in n0_i around inf
associate-/l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-/.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-sin.f32N/A
lift-sin.f3275.3
Applied rewrites75.3%
Taylor expanded in normAngle around 0
lift--.f3275.1
Applied rewrites75.1%
if -2.5e-24 < n0_i < 4.9999998e-22Initial program 96.4%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.5%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in n0_i around 0
lower-*.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f3264.4
Applied rewrites64.4%
Taylor expanded in normAngle around 0
Applied rewrites63.6%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (if (<= n0_i -2.499999999549897e-24) n0_i (if (<= n0_i 3.99999987306209e-21) (* u n1_i) n0_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if (n0_i <= -2.499999999549897e-24f) {
tmp = n0_i;
} else if (n0_i <= 3.99999987306209e-21f) {
tmp = u * n1_i;
} else {
tmp = n0_i;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: tmp
if (n0_i <= (-2.499999999549897e-24)) then
tmp = n0_i
else if (n0_i <= 3.99999987306209e-21) then
tmp = u * n1_i
else
tmp = n0_i
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if (n0_i <= Float32(-2.499999999549897e-24)) tmp = n0_i; elseif (n0_i <= Float32(3.99999987306209e-21)) tmp = Float32(u * n1_i); else tmp = n0_i; end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); if (n0_i <= single(-2.499999999549897e-24)) tmp = n0_i; elseif (n0_i <= single(3.99999987306209e-21)) tmp = u * n1_i; else tmp = n0_i; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -2.499999999549897 \cdot 10^{-24}:\\
\;\;\;\;n0\_i\\
\mathbf{elif}\;n0\_i \leq 3.99999987306209 \cdot 10^{-21}:\\
\;\;\;\;u \cdot n1\_i\\
\mathbf{else}:\\
\;\;\;\;n0\_i\\
\end{array}
\end{array}
if n0_i < -2.5e-24 or 3.9999999e-21 < n0_i Initial program 97.8%
Taylor expanded in u around 0
Applied rewrites59.0%
if -2.5e-24 < n0_i < 3.9999999e-21Initial program 96.4%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.5%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.6%
Taylor expanded in n0_i around 0
lower-*.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f3263.8
Applied rewrites63.8%
Taylor expanded in normAngle around 0
Applied rewrites63.0%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (fma (- n1_i n0_i) u n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((n1_i - n0_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(n1_i - n0_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)
\end{array}
Initial program 97.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.8%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.0%
Taylor expanded in normAngle around 0
lower--.f3298.2
Applied rewrites98.2%
(FPCore (normAngle u n0_i n1_i) :precision binary32 n0_i)
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
code = n0_i
end function
function code(normAngle, u, n0_i, n1_i) return n0_i end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = n0_i; end
\begin{array}{l}
\\
n0\_i
\end{array}
Initial program 97.2%
Taylor expanded in u around 0
Applied rewrites46.3%
herbie shell --seed 2025093
(FPCore (normAngle u n0_i n1_i)
:name "Curve intersection, scale width based on ribbon orientation"
:precision binary32
:pre (and (and (and (and (<= 0.0 normAngle) (<= normAngle (/ PI 2.0))) (and (<= -1.0 n0_i) (<= n0_i 1.0))) (and (<= -1.0 n1_i) (<= n1_i 1.0))) (and (<= 2.328306437e-10 u) (<= u 1.0)))
(+ (* (* (sin (* (- 1.0 u) normAngle)) (/ 1.0 (sin normAngle))) n0_i) (* (* (sin (* u normAngle)) (/ 1.0 (sin normAngle))) n1_i)))