James Kanze US/ESC 60/3/141 #40763 (kanze@lts.sel.alcatel.de) wrote:: There is currently a proposal before the C standardization committee: to do something like this. It actually goes considerably farther: for: example, most of the time, you need a minimum of n bits, but sometimes: you need exactly n bits (in which case, the compiler must typically: generate masking operations). And when you only need the minimum, you: may want the actual type optimized for either speed or space.

A few years ago we did some work on an optimising compiler for
bit-serial array processors that kept track of the precision of
operations. We did this because on a bit-serial processor every extra
bit of precision needs an extra cycle to calculate. We could bound the
operations since, when adding two three bit numbers together you knew
that the result would fit in four bits even if you didn't know the
run-time values. This approach worked well for us because we were
doing image processing which is mostly short-integer arithmetic.

We never wrote the work up, although I believe that something similar
was done in the FORTRAN compiler for the ICL DAP. Does anybody know of
any similar work? If C is going to acquire resolution specifiers
then maybe we should revive the work: there's a whole new class of
optimisations here.