link statically with libc?

Hal Daume
Thu, 7 Aug 2003 08:09:19 -0700

> > I don't know how the Ada guys do it.  Perhaps they have an alternate
> > set of compiled libraries with bounds-checking turned off?
> Me neither, I've just heard the idea discussed, not the actual
> technology.=20

I know O'Caml does this too (-unsafe as a compiler flag gives you unsafe
array accesses).  I've found in that context, I get as much as a 15%
speedup over not having -unsafe.  Admittedly this is on an extremely
array-intensive application, but it certainly can be a win.

On a related note, I know that the IBM Java compiler (I'm blanking on
the name right now) gets a lot of its speedups over Sun by lifting
bounds checks out of loops.  That is, if you have:

  for (int i=3D0; i<1000; i++) {
    acc +=3D arr[i];

in traditional Sun javac, you get something that basically looks like:

  for (int i=3D0; i<1000; i++) {
    if i outside of arr bounds, throw exception
    acc +=3D arr[i];

but the IBM compiler will lift this out (under certain circumstances --
for instance, if 'acc' is not in scope of the catch) to:

  if 0 outside of arr bounds || 999 outside of arr bounds, throw
  for (int i=3D0; i<1000; i++) {
    // look ma, no checks
    acc +=3D arr[i];

does GHC do anything similar to this, or are we getting hit with array
checks at each and every read/write (modulo, of course, full laziness)?

 - Hal