Lambda the Ultimate

inactiveTopic A Hacker's Assistant
started 5/11/2003; 2:11:55 AM - last post 5/11/2003; 2:30:13 AM
Ehud Lamm - A Hacker's Assistant  blueArrow
5/11/2003; 2:11:55 AM (reads: 1464, responses: 1)
A Hacker's Assistant
Aha! is a program of the superoptimizer type that can be used to find short branch-free code sequences for certain simple functions such as
  • the absolute value function,
  • a comparison predicate such as and
  • swapping the two low-order bits of a register.
It works by exhaustive search over programs of a given length. As a practical matter the length is limited to four instructions for most machines.

It can be fun to play around with this program.

A perhaps more subtle thing to notice is that the function to be optimized is written in C, and the superoptimizer relies on the C compiler to compile it correctly. The optimizer itself doesn't understand C, nor does it have to.

Posted to fun by Ehud Lamm on 5/11/03; 2:15:43 AM

Ehud Lamm - Re: A Hacker's Assistant  blueArrow
5/11/2003; 2:30:13 AM (reads: 577, responses: 0)
The amazingly productive Guy Steele wrote the introduction to the book whose web site this software comes from. In his introduction Steele mentions the classic HAKMEM document from MIT (AI memo 239). If you haven't seen this already, now's your chance.