The example with function m in their "white paper" (<a href="http://www.supercompilers.com/white_paper.shtml" rel="nofollow">http://www.supercompilers.com/white_paper.shtml</a>) is still not optimized fully. One first inlines the successive values of y:<p><pre><code> if (x0<=0) y=0;
else
if (x0>=1) y=1;
else {
if ((2-3*x0)<=0) y=0;
else
if ((2-3*x0)>=1) y=1;
else {
if ((2-3*(2-3*x0))<=0) y=0;
else
if ((2-3*(2-3*x0))>=1) y=1;
else {
...
else {
y = (2-3*(2-3*(2-3*(2-3*(2-3*x0)))));
} } } } }
</code></pre>
These can be solved for x0.<p><pre><code> if (x0<=0) y=0;
else
if (x0>=1) y=1;
else {
if ((2/3)<=x0) y=0;
else
if ((1/3)>=x0) y=1;
else {
if (x0<=(4/9)) y=0;
else
if (x0>=(5/9)) y=1;
else {
...
else {
y = (2-3*(2-3*(2-3*(2-3*(2-3*x0)))));
} } } } }
</code></pre>
Obviously, because floating point arithmetic is not distributive or associative (or exact), the actual constants will be slightly different from 1/3, 2/3, etc.<p>This performs an average of .004 subtractions and multiplications compared to my estimate of .988 for their algorithm.<p>Since this will probably not give strictly matching results for values close to 1/3, 2/3, 4/9, 5/9, etc., this is technically "super optimization" rather than supercompilation.<p>Are there any optimizers you know of that could get this far?