preston@dawn.cs.rice.edu (Preston Briggs) writes:>It's similar to the idea of writing an exponential routine to search for>better ways to convert integer-multiply-by-a-constant to shifts, adds, and>subtracts. There are known routines that do a good job, but an optimal>translation requires exponential search. Therefore, build a searcher that>tries to beat your normal routine and let it run for a while (days, weeks,

I maintained just such a beast (written by Guy Steele).

It didn't search for ways to multiply by N. instead, it generated all
interesting combinations of the relevant instructions (up to some code
size that would be as slow as the general method). For each, it found out
*what* N that was equivalent to multiplying by. If the code combination
was better than the previous-best (for N), then, write it down. At the
end, sort and encode.

This code ran for days, but on a VAX 11/780. A 70-SPECint machine should
be able to do things like this in an afternoon.
--
Don D.C.Lindsay Carnegie Mellon Computer Science
--