
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dX.v))
(t_1 (* (floor w) dY.u))
(t_2 (* (floor w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4)))
(t_6 (/ 1.0 (sqrt (fmax t_3 t_5)))))
(if (>= t_3 t_5) (* t_6 t_0) (* t_6 t_4))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dX_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float t_6 = 1.0f / sqrtf(fmaxf(t_3, t_5));
float tmp;
if (t_3 >= t_5) {
tmp = t_6 * t_0;
} else {
tmp = t_6 * t_4;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dX_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = Float32(floor(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) t_6 = Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5))))) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_6 * t_0); else tmp = Float32(t_6 * t_4); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dX_46_v; t_1 = floor(w) * dY_46_u; t_2 = floor(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); t_6 = single(1.0) / sqrt(max(t_3, t_5)); tmp = single(0.0); if (t_3 >= t_5) tmp = t_6 * t_0; else tmp = t_6 * t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
t_6 := \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_6 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dX.v))
(t_1 (* (floor w) dY.u))
(t_2 (* (floor w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4)))
(t_6 (/ 1.0 (sqrt (fmax t_3 t_5)))))
(if (>= t_3 t_5) (* t_6 t_0) (* t_6 t_4))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dX_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float t_6 = 1.0f / sqrtf(fmaxf(t_3, t_5));
float tmp;
if (t_3 >= t_5) {
tmp = t_6 * t_0;
} else {
tmp = t_6 * t_4;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dX_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = Float32(floor(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) t_6 = Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5))))) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_6 * t_0); else tmp = Float32(t_6 * t_4); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dX_46_v; t_1 = floor(w) * dY_46_u; t_2 = floor(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); t_6 = single(1.0) / sqrt(max(t_3, t_5)); tmp = single(0.0); if (t_3 >= t_5) tmp = t_6 * t_0; else tmp = t_6 * t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
t_6 := \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_6 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\end{array}
\end{array}
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (pow (hypot t_0 (* (floor w) dY.u)) 2.0))
(t_2 (* dX.u (floor w)))
(t_3 (* dX.v (floor h)))
(t_4 (fmax (pow (hypot t_3 t_2) 2.0) t_1)))
(if (>= (pow (hypot t_2 t_3) 2.0) t_1)
(* dX.v (* (floor h) (pow t_4 -0.5)))
(/ t_0 (pow t_4 0.5)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dY_46_v;
float t_1 = powf(hypotf(t_0, (floorf(w) * dY_46_u)), 2.0f);
float t_2 = dX_46_u * floorf(w);
float t_3 = dX_46_v * floorf(h);
float t_4 = fmaxf(powf(hypotf(t_3, t_2), 2.0f), t_1);
float tmp;
if (powf(hypotf(t_2, t_3), 2.0f) >= t_1) {
tmp = dX_46_v * (floorf(h) * powf(t_4, -0.5f));
} else {
tmp = t_0 / powf(t_4, 0.5f);
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dY_46_v) t_1 = hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0) t_2 = Float32(dX_46_u * floor(w)) t_3 = Float32(dX_46_v * floor(h)) t_4 = ((hypot(t_3, t_2) ^ Float32(2.0)) != (hypot(t_3, t_2) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(t_3, t_2) ^ Float32(2.0)) : max((hypot(t_3, t_2) ^ Float32(2.0)), t_1)) tmp = Float32(0.0) if ((hypot(t_2, t_3) ^ Float32(2.0)) >= t_1) tmp = Float32(dX_46_v * Float32(floor(h) * (t_4 ^ Float32(-0.5)))); else tmp = Float32(t_0 / (t_4 ^ Float32(0.5))); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dY_46_v; t_1 = hypot(t_0, (floor(w) * dY_46_u)) ^ single(2.0); t_2 = dX_46_u * floor(w); t_3 = dX_46_v * floor(h); t_4 = max((hypot(t_3, t_2) ^ single(2.0)), t_1); tmp = single(0.0); if ((hypot(t_2, t_3) ^ single(2.0)) >= t_1) tmp = dX_46_v * (floor(h) * (t_4 ^ single(-0.5))); else tmp = t_0 / (t_4 ^ single(0.5)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_2 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_3 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_3, t\_2\right)\right)}^{2}, t\_1\right)\\
\mathbf{if}\;{\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2} \geq t\_1:\\
\;\;\;\;dX.v \cdot \left(\left\lfloorh\right\rfloor \cdot {t\_4}^{-0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{{t\_4}^{0.5}}\\
\end{array}
\end{array}
Initial program 75.3%
Simplified75.4%
Taylor expanded in w around 0 75.4%
Simplified75.4%
Applied egg-rr75.4%
Applied egg-rr75.5%
Final simplification75.5%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
(t_1 (pow (hypot (* dX.v (floor h)) (* dX.u (floor w))) 2.0))
(t_2 (sqrt (fmax t_1 t_0))))
(if (>= t_1 t_0) (* (floor h) (/ dX.v t_2)) (* (floor h) (/ dY.v t_2)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
float t_1 = powf(hypotf((dX_46_v * floorf(h)), (dX_46_u * floorf(w))), 2.0f);
float t_2 = sqrtf(fmaxf(t_1, t_0));
float tmp;
if (t_1 >= t_0) {
tmp = floorf(h) * (dX_46_v / t_2);
} else {
tmp = floorf(h) * (dY_46_v / t_2);
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0) t_1 = hypot(Float32(dX_46_v * floor(h)), Float32(dX_46_u * floor(w))) ^ Float32(2.0) t_2 = sqrt(((t_1 != t_1) ? t_0 : ((t_0 != t_0) ? t_1 : max(t_1, t_0)))) tmp = Float32(0.0) if (t_1 >= t_0) tmp = Float32(floor(h) * Float32(dX_46_v / t_2)); else tmp = Float32(floor(h) * Float32(dY_46_v / t_2)); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0); t_1 = hypot((dX_46_v * floor(h)), (dX_46_u * floor(w))) ^ single(2.0); t_2 = sqrt(max(t_1, t_0)); tmp = single(0.0); if (t_1 >= t_0) tmp = floor(h) * (dX_46_v / t_2); else tmp = floor(h) * (dY_46_v / t_2); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_1 := {\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}\\
t_2 := \sqrt{\mathsf{max}\left(t\_1, t\_0\right)}\\
\mathbf{if}\;t\_1 \geq t\_0:\\
\;\;\;\;\left\lfloorh\right\rfloor \cdot \frac{dX.v}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorh\right\rfloor \cdot \frac{dY.v}{t\_2}\\
\end{array}
\end{array}
Initial program 75.3%
Simplified75.4%
Taylor expanded in w around 0 75.4%
Simplified75.4%
Taylor expanded in dX.u around 0 75.1%
Simplified75.3%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.u (floor w)))
(t_1 (* (floor h) dY.v))
(t_2 (pow (hypot t_1 (* (floor w) dY.u)) 2.0))
(t_3 (* dX.v (floor h)))
(t_4 (fmax (pow (hypot t_3 t_0) 2.0) t_2))
(t_5 (pow t_4 -0.5)))
(if (<= dX.u 200.0)
(if (>= (pow t_3 2.0) t_2)
(* dX.v (* (floor h) t_5))
(/ t_1 (pow t_4 0.5)))
(if (>= (pow t_0 2.0) t_2) (/ t_3 (sqrt t_4)) (* t_1 t_5)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = dX_46_u * floorf(w);
float t_1 = floorf(h) * dY_46_v;
float t_2 = powf(hypotf(t_1, (floorf(w) * dY_46_u)), 2.0f);
float t_3 = dX_46_v * floorf(h);
float t_4 = fmaxf(powf(hypotf(t_3, t_0), 2.0f), t_2);
float t_5 = powf(t_4, -0.5f);
float tmp_1;
if (dX_46_u <= 200.0f) {
float tmp_2;
if (powf(t_3, 2.0f) >= t_2) {
tmp_2 = dX_46_v * (floorf(h) * t_5);
} else {
tmp_2 = t_1 / powf(t_4, 0.5f);
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= t_2) {
tmp_1 = t_3 / sqrtf(t_4);
} else {
tmp_1 = t_1 * t_5;
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_u * floor(w)) t_1 = Float32(floor(h) * dY_46_v) t_2 = hypot(t_1, Float32(floor(w) * dY_46_u)) ^ Float32(2.0) t_3 = Float32(dX_46_v * floor(h)) t_4 = ((hypot(t_3, t_0) ^ Float32(2.0)) != (hypot(t_3, t_0) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_3, t_0) ^ Float32(2.0)) : max((hypot(t_3, t_0) ^ Float32(2.0)), t_2)) t_5 = t_4 ^ Float32(-0.5) tmp_1 = Float32(0.0) if (dX_46_u <= Float32(200.0)) tmp_2 = Float32(0.0) if ((t_3 ^ Float32(2.0)) >= t_2) tmp_2 = Float32(dX_46_v * Float32(floor(h) * t_5)); else tmp_2 = Float32(t_1 / (t_4 ^ Float32(0.5))); end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= t_2) tmp_1 = Float32(t_3 / sqrt(t_4)); else tmp_1 = Float32(t_1 * t_5); end return tmp_1 end
function tmp_4 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = dX_46_u * floor(w); t_1 = floor(h) * dY_46_v; t_2 = hypot(t_1, (floor(w) * dY_46_u)) ^ single(2.0); t_3 = dX_46_v * floor(h); t_4 = max((hypot(t_3, t_0) ^ single(2.0)), t_2); t_5 = t_4 ^ single(-0.5); tmp_2 = single(0.0); if (dX_46_u <= single(200.0)) tmp_3 = single(0.0); if ((t_3 ^ single(2.0)) >= t_2) tmp_3 = dX_46_v * (floor(h) * t_5); else tmp_3 = t_1 / (t_4 ^ single(0.5)); end tmp_2 = tmp_3; elseif ((t_0 ^ single(2.0)) >= t_2) tmp_2 = t_3 / sqrt(t_4); else tmp_2 = t_1 * t_5; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_2 := {\left(\mathsf{hypot}\left(t\_1, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_3 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_3, t\_0\right)\right)}^{2}, t\_2\right)\\
t_5 := {t\_4}^{-0.5}\\
\mathbf{if}\;dX.u \leq 200:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_3}^{2} \geq t\_2:\\
\;\;\;\;dX.v \cdot \left(\left\lfloorh\right\rfloor \cdot t\_5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{{t\_4}^{0.5}}\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq t\_2:\\
\;\;\;\;\frac{t\_3}{\sqrt{t\_4}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot t\_5\\
\end{array}
\end{array}
if dX.u < 200Initial program 76.4%
Simplified76.6%
Taylor expanded in w around 0 76.6%
Simplified76.6%
Applied egg-rr76.6%
Applied egg-rr76.7%
Taylor expanded in dX.u around 0 68.8%
unpow268.8%
unpow268.8%
swap-sqr68.8%
unpow268.8%
Simplified68.8%
if 200 < dX.u Initial program 71.8%
Simplified71.9%
Taylor expanded in w around 0 71.8%
Simplified71.8%
Taylor expanded in dX.u around inf 68.8%
unpow268.8%
unpow268.8%
swap-sqr68.8%
unpow268.8%
Simplified68.8%
Taylor expanded in dX.u around 0 68.8%
Simplified69.3%
Final simplification68.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* dX.v (floor h)))
(t_2 (* dX.u (floor w)))
(t_3 (pow t_2 2.0))
(t_4 (pow (hypot t_0 (* (floor w) dY.u)) 2.0))
(t_5 (pow (fmax (pow (hypot t_1 t_2) 2.0) t_4) -0.5))
(t_6 (* (floor h) (* dY.v t_5))))
(if (<= dY.u 300.0)
(if (>= t_3 (pow t_0 2.0)) (* t_1 t_5) t_6)
(if (>= t_3 t_4)
(* t_1 (pow (fmax (* (pow dX.u 2.0) (pow (floor w) 2.0)) t_4) -0.5))
t_6))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dY_46_v;
float t_1 = dX_46_v * floorf(h);
float t_2 = dX_46_u * floorf(w);
float t_3 = powf(t_2, 2.0f);
float t_4 = powf(hypotf(t_0, (floorf(w) * dY_46_u)), 2.0f);
float t_5 = powf(fmaxf(powf(hypotf(t_1, t_2), 2.0f), t_4), -0.5f);
float t_6 = floorf(h) * (dY_46_v * t_5);
float tmp_1;
if (dY_46_u <= 300.0f) {
float tmp_2;
if (t_3 >= powf(t_0, 2.0f)) {
tmp_2 = t_1 * t_5;
} else {
tmp_2 = t_6;
}
tmp_1 = tmp_2;
} else if (t_3 >= t_4) {
tmp_1 = t_1 * powf(fmaxf((powf(dX_46_u, 2.0f) * powf(floorf(w), 2.0f)), t_4), -0.5f);
} else {
tmp_1 = t_6;
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dY_46_v) t_1 = Float32(dX_46_v * floor(h)) t_2 = Float32(dX_46_u * floor(w)) t_3 = t_2 ^ Float32(2.0) t_4 = hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0) t_5 = (((hypot(t_1, t_2) ^ Float32(2.0)) != (hypot(t_1, t_2) ^ Float32(2.0))) ? t_4 : ((t_4 != t_4) ? (hypot(t_1, t_2) ^ Float32(2.0)) : max((hypot(t_1, t_2) ^ Float32(2.0)), t_4))) ^ Float32(-0.5) t_6 = Float32(floor(h) * Float32(dY_46_v * t_5)) tmp_1 = Float32(0.0) if (dY_46_u <= Float32(300.0)) tmp_2 = Float32(0.0) if (t_3 >= (t_0 ^ Float32(2.0))) tmp_2 = Float32(t_1 * t_5); else tmp_2 = t_6; end tmp_1 = tmp_2; elseif (t_3 >= t_4) tmp_1 = Float32(t_1 * (((Float32((dX_46_u ^ Float32(2.0)) * (floor(w) ^ Float32(2.0))) != Float32((dX_46_u ^ Float32(2.0)) * (floor(w) ^ Float32(2.0)))) ? t_4 : ((t_4 != t_4) ? Float32((dX_46_u ^ Float32(2.0)) * (floor(w) ^ Float32(2.0))) : max(Float32((dX_46_u ^ Float32(2.0)) * (floor(w) ^ Float32(2.0))), t_4))) ^ Float32(-0.5))); else tmp_1 = t_6; end return tmp_1 end
function tmp_4 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dY_46_v; t_1 = dX_46_v * floor(h); t_2 = dX_46_u * floor(w); t_3 = t_2 ^ single(2.0); t_4 = hypot(t_0, (floor(w) * dY_46_u)) ^ single(2.0); t_5 = max((hypot(t_1, t_2) ^ single(2.0)), t_4) ^ single(-0.5); t_6 = floor(h) * (dY_46_v * t_5); tmp_2 = single(0.0); if (dY_46_u <= single(300.0)) tmp_3 = single(0.0); if (t_3 >= (t_0 ^ single(2.0))) tmp_3 = t_1 * t_5; else tmp_3 = t_6; end tmp_2 = tmp_3; elseif (t_3 >= t_4) tmp_2 = t_1 * (max(((dX_46_u ^ single(2.0)) * (floor(w) ^ single(2.0))), t_4) ^ single(-0.5)); else tmp_2 = t_6; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_2 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_3 := {t\_2}^{2}\\
t_4 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_5 := {\left(\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2}, t\_4\right)\right)}^{-0.5}\\
t_6 := \left\lfloorh\right\rfloor \cdot \left(dY.v \cdot t\_5\right)\\
\mathbf{if}\;dY.u \leq 300:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_3 \geq {t\_0}^{2}:\\
\;\;\;\;t\_1 \cdot t\_5\\
\mathbf{else}:\\
\;\;\;\;t\_6\\
\end{array}\\
\mathbf{elif}\;t\_3 \geq t\_4:\\
\;\;\;\;t\_1 \cdot {\left(\mathsf{max}\left({dX.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2}, t\_4\right)\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;t\_6\\
\end{array}
\end{array}
if dY.u < 300Initial program 76.7%
Simplified76.8%
Taylor expanded in w around 0 76.5%
Simplified76.4%
Taylor expanded in dX.u around inf 66.3%
unpow266.3%
unpow266.3%
swap-sqr66.3%
unpow266.3%
Simplified66.3%
Taylor expanded in dX.u around 0 66.3%
Simplified66.4%
Taylor expanded in dY.v around inf 64.7%
*-commutative64.7%
unpow264.7%
unpow264.7%
swap-sqr64.7%
unpow264.7%
Simplified64.7%
if 300 < dY.u Initial program 71.6%
Simplified71.7%
Taylor expanded in w around 0 71.3%
Simplified71.4%
Taylor expanded in dX.u around inf 63.1%
unpow263.1%
unpow263.1%
swap-sqr63.1%
unpow263.1%
Simplified63.1%
Taylor expanded in dX.u around 0 63.2%
Simplified63.4%
Taylor expanded in dX.v around 0 63.5%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.v (floor h)))
(t_1 (* dX.u (floor w)))
(t_2 (pow t_1 2.0))
(t_3 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0)))
(if (>= t_2 t_3)
(* t_0 (pow (fmax (pow (hypot t_0 t_1) 2.0) t_3) -0.5))
(* (floor h) (* dY.v (pow (fmax t_2 t_3) -0.5))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = dX_46_v * floorf(h);
float t_1 = dX_46_u * floorf(w);
float t_2 = powf(t_1, 2.0f);
float t_3 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
float tmp;
if (t_2 >= t_3) {
tmp = t_0 * powf(fmaxf(powf(hypotf(t_0, t_1), 2.0f), t_3), -0.5f);
} else {
tmp = floorf(h) * (dY_46_v * powf(fmaxf(t_2, t_3), -0.5f));
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_v * floor(h)) t_1 = Float32(dX_46_u * floor(w)) t_2 = t_1 ^ Float32(2.0) t_3 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0) tmp = Float32(0.0) if (t_2 >= t_3) tmp = Float32(t_0 * ((((hypot(t_0, t_1) ^ Float32(2.0)) != (hypot(t_0, t_1) ^ Float32(2.0))) ? t_3 : ((t_3 != t_3) ? (hypot(t_0, t_1) ^ Float32(2.0)) : max((hypot(t_0, t_1) ^ Float32(2.0)), t_3))) ^ Float32(-0.5))); else tmp = Float32(floor(h) * Float32(dY_46_v * (((t_2 != t_2) ? t_3 : ((t_3 != t_3) ? t_2 : max(t_2, t_3))) ^ Float32(-0.5)))); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = dX_46_v * floor(h); t_1 = dX_46_u * floor(w); t_2 = t_1 ^ single(2.0); t_3 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0); tmp = single(0.0); if (t_2 >= t_3) tmp = t_0 * (max((hypot(t_0, t_1) ^ single(2.0)), t_3) ^ single(-0.5)); else tmp = floor(h) * (dY_46_v * (max(t_2, t_3) ^ single(-0.5))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_1 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_2 := {t\_1}^{2}\\
t_3 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
\mathbf{if}\;t\_2 \geq t\_3:\\
\;\;\;\;t\_0 \cdot {\left(\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}, t\_3\right)\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot {\left(\mathsf{max}\left(t\_2, t\_3\right)\right)}^{-0.5}\right)\\
\end{array}
\end{array}
Initial program 75.3%
Simplified75.4%
Taylor expanded in w around 0 75.1%
Simplified75.1%
Taylor expanded in dX.u around inf 65.4%
unpow265.4%
unpow265.4%
swap-sqr65.4%
unpow265.4%
Simplified65.4%
Taylor expanded in dX.u around 0 65.5%
Simplified65.6%
Taylor expanded in dX.v around 0 68.6%
unpow268.6%
unpow268.6%
swap-sqr68.6%
unpow268.6%
Simplified68.6%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* (floor h) dY.v))
(t_2 (* dX.v (floor h)))
(t_3 (* dX.u (floor w)))
(t_4
(pow (fmax (pow (hypot t_2 t_3) 2.0) (pow (hypot t_1 t_0) 2.0)) -0.5))
(t_5 (* (floor h) (* dY.v t_4)))
(t_6 (* t_2 t_4))
(t_7 (pow t_3 2.0)))
(if (<= dY.u 60000.0)
(if (>= t_7 (pow t_1 2.0)) t_6 t_5)
(if (>= t_7 (pow t_0 2.0)) t_6 t_5))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(w) * dY_46_u;
float t_1 = floorf(h) * dY_46_v;
float t_2 = dX_46_v * floorf(h);
float t_3 = dX_46_u * floorf(w);
float t_4 = powf(fmaxf(powf(hypotf(t_2, t_3), 2.0f), powf(hypotf(t_1, t_0), 2.0f)), -0.5f);
float t_5 = floorf(h) * (dY_46_v * t_4);
float t_6 = t_2 * t_4;
float t_7 = powf(t_3, 2.0f);
float tmp_1;
if (dY_46_u <= 60000.0f) {
float tmp_2;
if (t_7 >= powf(t_1, 2.0f)) {
tmp_2 = t_6;
} else {
tmp_2 = t_5;
}
tmp_1 = tmp_2;
} else if (t_7 >= powf(t_0, 2.0f)) {
tmp_1 = t_6;
} else {
tmp_1 = t_5;
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dY_46_u) t_1 = Float32(floor(h) * dY_46_v) t_2 = Float32(dX_46_v * floor(h)) t_3 = Float32(dX_46_u * floor(w)) t_4 = (((hypot(t_2, t_3) ^ Float32(2.0)) != (hypot(t_2, t_3) ^ Float32(2.0))) ? (hypot(t_1, t_0) ^ Float32(2.0)) : (((hypot(t_1, t_0) ^ Float32(2.0)) != (hypot(t_1, t_0) ^ Float32(2.0))) ? (hypot(t_2, t_3) ^ Float32(2.0)) : max((hypot(t_2, t_3) ^ Float32(2.0)), (hypot(t_1, t_0) ^ Float32(2.0))))) ^ Float32(-0.5) t_5 = Float32(floor(h) * Float32(dY_46_v * t_4)) t_6 = Float32(t_2 * t_4) t_7 = t_3 ^ Float32(2.0) tmp_1 = Float32(0.0) if (dY_46_u <= Float32(60000.0)) tmp_2 = Float32(0.0) if (t_7 >= (t_1 ^ Float32(2.0))) tmp_2 = t_6; else tmp_2 = t_5; end tmp_1 = tmp_2; elseif (t_7 >= (t_0 ^ Float32(2.0))) tmp_1 = t_6; else tmp_1 = t_5; end return tmp_1 end
function tmp_4 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(w) * dY_46_u; t_1 = floor(h) * dY_46_v; t_2 = dX_46_v * floor(h); t_3 = dX_46_u * floor(w); t_4 = max((hypot(t_2, t_3) ^ single(2.0)), (hypot(t_1, t_0) ^ single(2.0))) ^ single(-0.5); t_5 = floor(h) * (dY_46_v * t_4); t_6 = t_2 * t_4; t_7 = t_3 ^ single(2.0); tmp_2 = single(0.0); if (dY_46_u <= single(60000.0)) tmp_3 = single(0.0); if (t_7 >= (t_1 ^ single(2.0))) tmp_3 = t_6; else tmp_3 = t_5; end tmp_2 = tmp_3; elseif (t_7 >= (t_0 ^ single(2.0))) tmp_2 = t_6; else tmp_2 = t_5; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_2 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_3 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_4 := {\left(\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)\right)}^{-0.5}\\
t_5 := \left\lfloorh\right\rfloor \cdot \left(dY.v \cdot t\_4\right)\\
t_6 := t\_2 \cdot t\_4\\
t_7 := {t\_3}^{2}\\
\mathbf{if}\;dY.u \leq 60000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_7 \geq {t\_1}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}\\
\mathbf{elif}\;t\_7 \geq {t\_0}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
\end{array}
if dY.u < 6e4Initial program 76.4%
Simplified76.5%
Taylor expanded in w around 0 76.2%
Simplified76.2%
Taylor expanded in dX.u around inf 65.6%
unpow265.6%
unpow265.6%
swap-sqr65.6%
unpow265.6%
Simplified65.6%
Taylor expanded in dX.u around 0 65.6%
Simplified65.7%
Taylor expanded in dY.v around inf 64.1%
*-commutative64.1%
unpow264.1%
unpow264.1%
swap-sqr64.1%
unpow264.1%
Simplified64.1%
if 6e4 < dY.u Initial program 71.5%
Simplified71.8%
Taylor expanded in w around 0 71.4%
Simplified71.3%
Taylor expanded in dX.u around inf 64.9%
unpow264.9%
unpow264.9%
swap-sqr64.9%
unpow264.9%
Simplified64.9%
Taylor expanded in dX.u around 0 65.0%
Simplified65.2%
Taylor expanded in dY.v around 0 65.2%
*-commutative65.2%
unpow265.2%
unpow265.2%
swap-sqr65.2%
unpow265.2%
Simplified65.2%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* dX.v (floor h)))
(t_2 (* dX.u (floor w)))
(t_3
(pow
(fmax
(pow (hypot t_1 t_2) 2.0)
(pow (hypot t_0 (* (floor w) dY.u)) 2.0))
-0.5)))
(if (>= (pow t_2 2.0) (pow t_0 2.0))
(* t_1 t_3)
(* (floor h) (* dY.v t_3)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dY_46_v;
float t_1 = dX_46_v * floorf(h);
float t_2 = dX_46_u * floorf(w);
float t_3 = powf(fmaxf(powf(hypotf(t_1, t_2), 2.0f), powf(hypotf(t_0, (floorf(w) * dY_46_u)), 2.0f)), -0.5f);
float tmp;
if (powf(t_2, 2.0f) >= powf(t_0, 2.0f)) {
tmp = t_1 * t_3;
} else {
tmp = floorf(h) * (dY_46_v * t_3);
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dY_46_v) t_1 = Float32(dX_46_v * floor(h)) t_2 = Float32(dX_46_u * floor(w)) t_3 = (((hypot(t_1, t_2) ^ Float32(2.0)) != (hypot(t_1, t_2) ^ Float32(2.0))) ? (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)) : (((hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)) != (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0))) ? (hypot(t_1, t_2) ^ Float32(2.0)) : max((hypot(t_1, t_2) ^ Float32(2.0)), (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0))))) ^ Float32(-0.5) tmp = Float32(0.0) if ((t_2 ^ Float32(2.0)) >= (t_0 ^ Float32(2.0))) tmp = Float32(t_1 * t_3); else tmp = Float32(floor(h) * Float32(dY_46_v * t_3)); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dY_46_v; t_1 = dX_46_v * floor(h); t_2 = dX_46_u * floor(w); t_3 = max((hypot(t_1, t_2) ^ single(2.0)), (hypot(t_0, (floor(w) * dY_46_u)) ^ single(2.0))) ^ single(-0.5); tmp = single(0.0); if ((t_2 ^ single(2.0)) >= (t_0 ^ single(2.0))) tmp = t_1 * t_3; else tmp = floor(h) * (dY_46_v * t_3); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_2 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_3 := {\left(\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_0, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)\right)}^{-0.5}\\
\mathbf{if}\;{t\_2}^{2} \geq {t\_0}^{2}:\\
\;\;\;\;t\_1 \cdot t\_3\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot t\_3\right)\\
\end{array}
\end{array}
Initial program 75.3%
Simplified75.4%
Taylor expanded in w around 0 75.1%
Simplified75.1%
Taylor expanded in dX.u around inf 65.4%
unpow265.4%
unpow265.4%
swap-sqr65.4%
unpow265.4%
Simplified65.4%
Taylor expanded in dX.u around 0 65.5%
Simplified65.6%
Taylor expanded in dY.v around inf 59.9%
*-commutative59.9%
unpow259.9%
unpow259.9%
swap-sqr59.9%
unpow259.9%
Simplified59.9%
herbie shell --seed 2024141
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:name "Anisotropic x16 LOD (line direction, v)"
:precision binary32
:pre (and (and (and (and (and (and (and (<= 1.0 w) (<= w 16384.0)) (and (<= 1.0 h) (<= h 16384.0))) (and (<= 1e-20 (fabs dX.u)) (<= (fabs dX.u) 1e+20))) (and (<= 1e-20 (fabs dX.v)) (<= (fabs dX.v) 1e+20))) (and (<= 1e-20 (fabs dY.u)) (<= (fabs dY.u) 1e+20))) (and (<= 1e-20 (fabs dY.v)) (<= (fabs dY.v) 1e+20))) (== maxAniso 16.0))
(if (>= (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))) (* (/ 1.0 (sqrt (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))))) (* (floor h) dX.v)) (* (/ 1.0 (sqrt (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))))) (* (floor h) dY.v))))