A Comparison of Array Bounds Checking on Superscalar and VLIW Architectures

Several programming languages guarantee that array subscripts are checked to ensure they are within the array bounds. While this guarantee improves the correctness and security of array-based code, it adds overhead to array references. This is unacceptable in array-intensive scientific codes; some estimates show more than 60% overhead for array bounds checking. This performance limitation is a significant obstacle preventing the scientific community from adopting compiler-enforced array bounds checks (e.g., Fortran, if bounds checks are enabled, or Java). Previous research has explored optimizations to statically eliminate bounds checks, but the dynamic nature of many scientific codes makes this difficult. We are interested in techniques for reducing the cost of array bounds checks, with the goal of improving the performance of scientific codes. In this paper we evaluate the potential gain of such techniques by analyzing several scientific benchmarks on two different types of architectures. We performed experiments on a Pentium 3, Pentium 4, and an Itanium 1; results show that bounds checking on the Pentium 4 has moderate overhead, averaging 34%. The Itanium, however, incurs much more significant overhead, averaging 74%. Finally, the Pentium 3 has the largest overhead, at 117%. For this paper we added bounds checks to C through bcc, a bounds checking extension to gcc. We expect array bounds checking overhead to be similar in other languages.