
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
float code(float s, float u) {
return s * logf((1.0f / (1.0f - (4.0f * u))));
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
function code(s, u) return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u))))) end
function tmp = code(s, u) tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u)))); end
\begin{array}{l}
\\
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (s u) :precision binary32 (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
float code(float s, float u) {
return s * logf((1.0f / (1.0f - (4.0f * u))));
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
function code(s, u) return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u))))) end
function tmp = code(s, u) tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u)))); end
\begin{array}{l}
\\
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)
\end{array}
(FPCore (s u)
:precision binary32
(if (<= u 0.010499999858438969)
(*
(* (- (* (- (* (- (* -64.0 u) 21.333333333333332) u) 8.0) u) 4.0) u)
(- s))
(*
s
(fabs
(- (log (- (- (* (* u u) 16.0) 1.0))) (log (- (* (- -4.0) u) -1.0)))))))
float code(float s, float u) {
float tmp;
if (u <= 0.010499999858438969f) {
tmp = (((((((-64.0f * u) - 21.333333333333332f) * u) - 8.0f) * u) - 4.0f) * u) * -s;
} else {
tmp = s * fabsf((logf(-(((u * u) * 16.0f) - 1.0f)) - logf(((-(-4.0f) * u) - -1.0f))));
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
real(4) :: tmp
if (u <= 0.010499999858438969e0) then
tmp = ((((((((-64.0e0) * u) - 21.333333333333332e0) * u) - 8.0e0) * u) - 4.0e0) * u) * -s
else
tmp = s * abs((log(-(((u * u) * 16.0e0) - 1.0e0)) - log(((-(-4.0e0) * u) - (-1.0e0)))))
end if
code = tmp
end function
function code(s, u) tmp = Float32(0.0) if (u <= Float32(0.010499999858438969)) tmp = Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(-64.0) * u) - Float32(21.333333333333332)) * u) - Float32(8.0)) * u) - Float32(4.0)) * u) * Float32(-s)); else tmp = Float32(s * abs(Float32(log(Float32(-Float32(Float32(Float32(u * u) * Float32(16.0)) - Float32(1.0)))) - log(Float32(Float32(Float32(-Float32(-4.0)) * u) - Float32(-1.0)))))); end return tmp end
function tmp_2 = code(s, u) tmp = single(0.0); if (u <= single(0.010499999858438969)) tmp = (((((((single(-64.0) * u) - single(21.333333333333332)) * u) - single(8.0)) * u) - single(4.0)) * u) * -s; else tmp = s * abs((log(-(((u * u) * single(16.0)) - single(1.0))) - log(((-single(-4.0) * u) - single(-1.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u \leq 0.010499999858438969:\\
\;\;\;\;\left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)\\
\mathbf{else}:\\
\;\;\;\;s \cdot \left|\log \left(-\left(\left(u \cdot u\right) \cdot 16 - 1\right)\right) - \log \left(\left(--4\right) \cdot u - -1\right)\right|\\
\end{array}
\end{array}
if u < 0.0104999999Initial program 55.6%
Applied rewrites27.8%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3232.9
Applied rewrites32.9%
lift-log.f32N/A
lift-exp.f32N/A
rem-log-exp97.4
Applied rewrites97.4%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3298.6
Applied rewrites98.6%
if 0.0104999999 < u Initial program 96.4%
Applied rewrites38.9%
Applied rewrites96.7%
Final simplification98.3%
(FPCore (s u)
:precision binary32
(let* ((t_0 (- 1.0 (* 4.0 u))))
(if (<= t_0 0.9599999785423279)
(* s (log (/ 1.0 t_0)))
(*
(* (- (* (- (* (- (* -64.0 u) 21.333333333333332) u) 8.0) u) 4.0) u)
(- s)))))
float code(float s, float u) {
float t_0 = 1.0f - (4.0f * u);
float tmp;
if (t_0 <= 0.9599999785423279f) {
tmp = s * logf((1.0f / t_0));
} else {
tmp = (((((((-64.0f * u) - 21.333333333333332f) * u) - 8.0f) * u) - 4.0f) * u) * -s;
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
real(4) :: t_0
real(4) :: tmp
t_0 = 1.0e0 - (4.0e0 * u)
if (t_0 <= 0.9599999785423279e0) then
tmp = s * log((1.0e0 / t_0))
else
tmp = ((((((((-64.0e0) * u) - 21.333333333333332e0) * u) - 8.0e0) * u) - 4.0e0) * u) * -s
end if
code = tmp
end function
function code(s, u) t_0 = Float32(Float32(1.0) - Float32(Float32(4.0) * u)) tmp = Float32(0.0) if (t_0 <= Float32(0.9599999785423279)) tmp = Float32(s * log(Float32(Float32(1.0) / t_0))); else tmp = Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(-64.0) * u) - Float32(21.333333333333332)) * u) - Float32(8.0)) * u) - Float32(4.0)) * u) * Float32(-s)); end return tmp end
function tmp_2 = code(s, u) t_0 = single(1.0) - (single(4.0) * u); tmp = single(0.0); if (t_0 <= single(0.9599999785423279)) tmp = s * log((single(1.0) / t_0)); else tmp = (((((((single(-64.0) * u) - single(21.333333333333332)) * u) - single(8.0)) * u) - single(4.0)) * u) * -s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - 4 \cdot u\\
\mathbf{if}\;t\_0 \leq 0.9599999785423279:\\
\;\;\;\;s \cdot \log \left(\frac{1}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)\\
\end{array}
\end{array}
if (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u)) < 0.959999979Initial program 96.3%
if 0.959999979 < (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u)) Initial program 55.4%
Applied rewrites28.2%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3233.1
Applied rewrites33.1%
lift-log.f32N/A
lift-exp.f32N/A
rem-log-exp97.5
Applied rewrites97.5%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
Final simplification98.2%
(FPCore (s u) :precision binary32 (* (* (- (* (- (* (- (* -64.0 u) 21.333333333333332) u) 8.0) u) 4.0) u) (- s)))
float code(float s, float u) {
return (((((((-64.0f * u) - 21.333333333333332f) * u) - 8.0f) * u) - 4.0f) * u) * -s;
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((((((((-64.0e0) * u) - 21.333333333333332e0) * u) - 8.0e0) * u) - 4.0e0) * u) * -s
end function
function code(s, u) return Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(-64.0) * u) - Float32(21.333333333333332)) * u) - Float32(8.0)) * u) - Float32(4.0)) * u) * Float32(-s)) end
function tmp = code(s, u) tmp = (((((((single(-64.0) * u) - single(21.333333333333332)) * u) - single(8.0)) * u) - single(4.0)) * u) * -s; end
\begin{array}{l}
\\
\left(\left(\left(\left(-64 \cdot u - 21.333333333333332\right) \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)
\end{array}
Initial program 62.8%
Applied rewrites25.4%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3230.1
Applied rewrites30.1%
lift-log.f32N/A
lift-exp.f32N/A
rem-log-exp89.6
Applied rewrites89.6%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3291.9
Applied rewrites91.9%
Final simplification91.9%
(FPCore (s u) :precision binary32 (* (* (- (* (- (* -21.333333333333332 u) 8.0) u) 4.0) u) (- s)))
float code(float s, float u) {
return (((((-21.333333333333332f * u) - 8.0f) * u) - 4.0f) * u) * -s;
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((((((-21.333333333333332e0) * u) - 8.0e0) * u) - 4.0e0) * u) * -s
end function
function code(s, u) return Float32(Float32(Float32(Float32(Float32(Float32(Float32(-21.333333333333332) * u) - Float32(8.0)) * u) - Float32(4.0)) * u) * Float32(-s)) end
function tmp = code(s, u) tmp = (((((single(-21.333333333333332) * u) - single(8.0)) * u) - single(4.0)) * u) * -s; end
\begin{array}{l}
\\
\left(\left(\left(-21.333333333333332 \cdot u - 8\right) \cdot u - 4\right) \cdot u\right) \cdot \left(-s\right)
\end{array}
Initial program 62.8%
Applied rewrites25.2%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3230.1
Applied rewrites30.1%
lift-log.f32N/A
lift-exp.f32N/A
rem-log-exp89.6
Applied rewrites89.6%
Final simplification89.6%
(FPCore (s u) :precision binary32 (* s (- (* (* 8.0 u) u) (* -4.0 u))))
float code(float s, float u) {
return s * (((8.0f * u) * u) - (-4.0f * u));
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * (((8.0e0 * u) * u) - ((-4.0e0) * u))
end function
function code(s, u) return Float32(s * Float32(Float32(Float32(Float32(8.0) * u) * u) - Float32(Float32(-4.0) * u))) end
function tmp = code(s, u) tmp = s * (((single(8.0) * u) * u) - (single(-4.0) * u)); end
\begin{array}{l}
\\
s \cdot \left(\left(8 \cdot u\right) \cdot u - -4 \cdot u\right)
\end{array}
Initial program 62.8%
Taylor expanded in u around 0
lower-*.f3273.5
Applied rewrites73.5%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.5
Applied rewrites73.3%
Applied rewrites85.6%
(FPCore (s u) :precision binary32 (* s (* (- 4.0 (* -8.0 u)) u)))
float code(float s, float u) {
return s * ((4.0f - (-8.0f * u)) * u);
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((4.0e0 - ((-8.0e0) * u)) * u)
end function
function code(s, u) return Float32(s * Float32(Float32(Float32(4.0) - Float32(Float32(-8.0) * u)) * u)) end
function tmp = code(s, u) tmp = s * ((single(4.0) - (single(-8.0) * u)) * u); end
\begin{array}{l}
\\
s \cdot \left(\left(4 - -8 \cdot u\right) \cdot u\right)
\end{array}
Initial program 62.8%
Taylor expanded in u around 0
lower-*.f3273.5
Applied rewrites73.5%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.5
Applied rewrites73.3%
Applied rewrites85.3%
(FPCore (s u) :precision binary32 (* s (* 4.0 u)))
float code(float s, float u) {
return s * (4.0f * u);
}
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(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * (4.0e0 * u)
end function
function code(s, u) return Float32(s * Float32(Float32(4.0) * u)) end
function tmp = code(s, u) tmp = s * (single(4.0) * u); end
\begin{array}{l}
\\
s \cdot \left(4 \cdot u\right)
\end{array}
Initial program 62.8%
Taylor expanded in u around 0
lower-*.f3273.5
Applied rewrites73.5%
herbie shell --seed 2024347
(FPCore (s u)
:name "Disney BSSRDF, sample scattering profile, lower"
:precision binary32
:pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 2.328306437e-10 u) (<= u 0.25)))
(* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))