
(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
(+
n0_i
(*
u
(+
n1_i
(+
(- n0_i)
(fma
(* -0.5 n0_i)
(* (* normAngle normAngle) u)
(*
(* normAngle normAngle)
(fma 0.5 n0_i (* 0.16666666666666666 (+ n1_i (- n0_i)))))))))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i + (u * (n1_i + (-n0_i + fmaf((-0.5f * n0_i), ((normAngle * normAngle) * u), ((normAngle * normAngle) * fmaf(0.5f, n0_i, (0.16666666666666666f * (n1_i + -n0_i))))))));
}
function code(normAngle, u, n0_i, n1_i) return Float32(n0_i + Float32(u * Float32(n1_i + Float32(Float32(-n0_i) + fma(Float32(Float32(-0.5) * n0_i), Float32(Float32(normAngle * normAngle) * u), Float32(Float32(normAngle * normAngle) * fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * Float32(n1_i + Float32(-n0_i)))))))))) end
\begin{array}{l}
\\
n0\_i + u \cdot \left(n1\_i + \left(\left(-n0\_i\right) + \mathsf{fma}\left(-0.5 \cdot n0\_i, \left(normAngle \cdot normAngle\right) \cdot u, \left(normAngle \cdot normAngle\right) \cdot \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i + \left(-n0\_i\right)\right)\right)\right)\right)\right)
\end{array}
Initial program 97.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in u around 0
lower-+.f32N/A
lower-*.f32N/A
lower-+.f32N/A
lower-+.f32N/A
Applied rewrites98.9%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(+
n0_i
(*
u
(-
(fma
(fma 0.16666666666666666 n1_i (* n0_i (- 0.3333333333333333 (* 0.5 u))))
(* normAngle normAngle)
n1_i)
n0_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i + (u * (fmaf(fmaf(0.16666666666666666f, n1_i, (n0_i * (0.3333333333333333f - (0.5f * u)))), (normAngle * normAngle), n1_i) - n0_i));
}
function code(normAngle, u, n0_i, n1_i) return Float32(n0_i + Float32(u * Float32(fma(fma(Float32(0.16666666666666666), n1_i, Float32(n0_i * Float32(Float32(0.3333333333333333) - Float32(Float32(0.5) * u)))), Float32(normAngle * normAngle), n1_i) - n0_i))) end
\begin{array}{l}
\\
n0\_i + u \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, n1\_i, n0\_i \cdot \left(0.3333333333333333 - 0.5 \cdot u\right)\right), normAngle \cdot normAngle, n1\_i\right) - n0\_i\right)
\end{array}
Initial program 97.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in u around 0
lower-+.f32N/A
lower-*.f32N/A
lower-+.f32N/A
lower-+.f32N/A
Applied rewrites98.9%
Taylor expanded in normAngle around 0
lower--.f32N/A
Applied rewrites98.9%
Taylor expanded in n0_i around 0
lower-fma.f32N/A
lower-*.f32N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-*.f3298.9
Applied rewrites98.9%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(+
n0_i
(*
u
(+
(+ n1_i (- n0_i))
(*
(* normAngle normAngle)
(fma 0.3333333333333333 n0_i (* 0.16666666666666666 n1_i)))))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i + (u * ((n1_i + -n0_i) + ((normAngle * normAngle) * fmaf(0.3333333333333333f, n0_i, (0.16666666666666666f * n1_i)))));
}
function code(normAngle, u, n0_i, n1_i) return Float32(n0_i + Float32(u * Float32(Float32(n1_i + Float32(-n0_i)) + Float32(Float32(normAngle * normAngle) * fma(Float32(0.3333333333333333), n0_i, Float32(Float32(0.16666666666666666) * n1_i)))))) end
\begin{array}{l}
\\
n0\_i + u \cdot \left(\left(n1\_i + \left(-n0\_i\right)\right) + \left(normAngle \cdot normAngle\right) \cdot \mathsf{fma}\left(0.3333333333333333, n0\_i, 0.16666666666666666 \cdot n1\_i\right)\right)
\end{array}
Initial program 97.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in u around 0
lower-+.f32N/A
lower-*.f32N/A
associate-+r+N/A
lower-+.f32N/A
lower-+.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
lower-fma.f32N/A
Applied rewrites98.9%
Taylor expanded in n0_i around 0
+-commutativeN/A
lower-fma.f32N/A
lower-*.f3298.9
Applied rewrites98.9%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(+
n0_i
(*
u
(+
n1_i
(+ (- n0_i) (* (* (* normAngle normAngle) n1_i) 0.16666666666666666))))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i + (u * (n1_i + (-n0_i + (((normAngle * normAngle) * n1_i) * 0.16666666666666666f))));
}
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 + (u * (n1_i + (-n0_i + (((normangle * normangle) * n1_i) * 0.16666666666666666e0))))
end function
function code(normAngle, u, n0_i, n1_i) return Float32(n0_i + Float32(u * Float32(n1_i + Float32(Float32(-n0_i) + Float32(Float32(Float32(normAngle * normAngle) * n1_i) * Float32(0.16666666666666666)))))) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = n0_i + (u * (n1_i + (-n0_i + (((normAngle * normAngle) * n1_i) * single(0.16666666666666666))))); end
\begin{array}{l}
\\
n0\_i + u \cdot \left(n1\_i + \left(\left(-n0\_i\right) + \left(\left(normAngle \cdot normAngle\right) \cdot n1\_i\right) \cdot 0.16666666666666666\right)\right)
\end{array}
Initial program 97.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in u around 0
lower-+.f32N/A
lower-*.f32N/A
lower-+.f32N/A
lower-+.f32N/A
Applied rewrites98.9%
Taylor expanded in n0_i around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
pow2N/A
lift-*.f3298.7
Applied rewrites98.7%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (+ n0_i (* u (- (fma (* 0.16666666666666666 n1_i) (* normAngle normAngle) n1_i) n0_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i + (u * (fmaf((0.16666666666666666f * n1_i), (normAngle * normAngle), n1_i) - n0_i));
}
function code(normAngle, u, n0_i, n1_i) return Float32(n0_i + Float32(u * Float32(fma(Float32(Float32(0.16666666666666666) * n1_i), Float32(normAngle * normAngle), n1_i) - n0_i))) end
\begin{array}{l}
\\
n0\_i + u \cdot \left(\mathsf{fma}\left(0.16666666666666666 \cdot n1\_i, normAngle \cdot normAngle, n1\_i\right) - n0\_i\right)
\end{array}
Initial program 97.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in u around 0
lower-+.f32N/A
lower-*.f32N/A
lower-+.f32N/A
lower-+.f32N/A
Applied rewrites98.9%
Taylor expanded in normAngle around 0
lower--.f32N/A
Applied rewrites98.9%
Taylor expanded in n0_i around 0
lower-*.f3298.7
Applied rewrites98.7%
(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.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in u around 0
lower-+.f32N/A
lower-*.f32N/A
associate-+r+N/A
lower-+.f32N/A
lower-+.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
lower-fma.f32N/A
Applied rewrites98.9%
Taylor expanded in normAngle around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f3298.1
Applied rewrites98.1%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (if (<= n0_i -1.0000000036274937e-15) (* n0_i (- 1.0 u)) (+ n0_i (* u n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if (n0_i <= -1.0000000036274937e-15f) {
tmp = n0_i * (1.0f - u);
} else {
tmp = n0_i + (u * n1_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 <= (-1.0000000036274937e-15)) then
tmp = n0_i * (1.0e0 - u)
else
tmp = n0_i + (u * n1_i)
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if (n0_i <= Float32(-1.0000000036274937e-15)) tmp = Float32(n0_i * Float32(Float32(1.0) - u)); else tmp = Float32(n0_i + Float32(u * n1_i)); end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); if (n0_i <= single(-1.0000000036274937e-15)) tmp = n0_i * (single(1.0) - u); else tmp = n0_i + (u * n1_i); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -1.0000000036274937 \cdot 10^{-15}:\\
\;\;\;\;n0\_i \cdot \left(1 - u\right)\\
\mathbf{else}:\\
\;\;\;\;n0\_i + u \cdot n1\_i\\
\end{array}
\end{array}
if n0_i < -1e-15Initial program 98.1%
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.f3284.3
Applied rewrites84.3%
Taylor expanded in normAngle around 0
lift--.f3283.9
Applied rewrites83.9%
if -1e-15 < n0_i Initial program 96.8%
Taylor expanded in normAngle around 0
Applied rewrites97.5%
Taylor expanded in u around 0
Applied rewrites83.5%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (* n0_i (- 1.0 u))))
(if (<= n0_i -4.00000012549758e-22)
t_0
(if (<= n0_i 1.0000000031710769e-28) (* n1_i u) 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 <= -4.00000012549758e-22f) {
tmp = t_0;
} else if (n0_i <= 1.0000000031710769e-28f) {
tmp = n1_i * u;
} 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 <= (-4.00000012549758e-22)) then
tmp = t_0
else if (n0_i <= 1.0000000031710769e-28) then
tmp = n1_i * u
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(-4.00000012549758e-22)) tmp = t_0; elseif (n0_i <= Float32(1.0000000031710769e-28)) tmp = Float32(n1_i * u); 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(-4.00000012549758e-22)) tmp = t_0; elseif (n0_i <= single(1.0000000031710769e-28)) tmp = n1_i * u; 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 -4.00000012549758 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n0\_i \leq 1.0000000031710769 \cdot 10^{-28}:\\
\;\;\;\;n1\_i \cdot u\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n0_i < -4.00000013e-22 or 1e-28 < n0_i Initial program 97.6%
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.f3273.0
Applied rewrites73.0%
Taylor expanded in normAngle around 0
lift--.f3272.7
Applied rewrites72.7%
if -4.00000013e-22 < n0_i < 1e-28Initial program 95.9%
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
lower-+.f32N/A
lower-*.f32N/A
associate-+r+N/A
lower-+.f32N/A
lower-+.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in n0_i around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
pow2N/A
lift-*.f3266.3
Applied rewrites66.3%
Taylor expanded in normAngle around 0
Applied rewrites65.3%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (if (<= n0_i -4.00000012549758e-22) n0_i (if (<= n0_i 2.0000000063421537e-28) (* n1_i u) n0_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if (n0_i <= -4.00000012549758e-22f) {
tmp = n0_i;
} else if (n0_i <= 2.0000000063421537e-28f) {
tmp = n1_i * u;
} 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 <= (-4.00000012549758e-22)) then
tmp = n0_i
else if (n0_i <= 2.0000000063421537e-28) then
tmp = n1_i * u
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(-4.00000012549758e-22)) tmp = n0_i; elseif (n0_i <= Float32(2.0000000063421537e-28)) tmp = Float32(n1_i * u); 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(-4.00000012549758e-22)) tmp = n0_i; elseif (n0_i <= single(2.0000000063421537e-28)) tmp = n1_i * u; else tmp = n0_i; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -4.00000012549758 \cdot 10^{-22}:\\
\;\;\;\;n0\_i\\
\mathbf{elif}\;n0\_i \leq 2.0000000063421537 \cdot 10^{-28}:\\
\;\;\;\;n1\_i \cdot u\\
\mathbf{else}:\\
\;\;\;\;n0\_i\\
\end{array}
\end{array}
if n0_i < -4.00000013e-22 or 2.00000001e-28 < n0_i Initial program 97.7%
Taylor expanded in u around 0
Applied rewrites56.8%
if -4.00000013e-22 < n0_i < 2.00000001e-28Initial program 95.9%
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
lower-+.f32N/A
lower-*.f32N/A
associate-+r+N/A
lower-+.f32N/A
lower-+.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in n0_i around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
pow2N/A
lift-*.f3266.2
Applied rewrites66.2%
Taylor expanded in normAngle around 0
Applied rewrites65.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.0%
Taylor expanded in u around 0
Applied rewrites46.6%
herbie shell --seed 2025116
(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)))