[Patch] natString.cc: Some fixes for bounds checking arithmet ic.
Dalibor Topic
robilad@kaffe.org
Wed Sep 24 19:52:00 GMT 2003
Boehm, Hans wrote:
> There's an orthogonal but related issue that might be worth mentioning.
> Last I looked some of the natString.cc routines that involve this
> bounds checking show up fairly high on profiles for SPECjbb and probably
> also real code. Most of the bounds checking is done with tests like
>
> if (a > b || c > d || e > f)
>
> My guess would be that on most architectures, it would be better to compile
> this as
>
> if ((long)((b - a) | (d - c) | (f - e)) < 0)
>
> i.e. or sign bits together, and do a single test and branch on the result.
> This reduces the number of branches, and thus avoids filling up branch
> prediction tables with this sort of stuff. It also clearly allows
> all the expressions to be scheduled in parallel.
this kind of optimizations is pretty much the thing I hoped would be
easy to come up with, test and implement with my 'bounds checking api'
idea. thanks! ;)
cheers,
dalibor topic
More information about the Java-patches
mailing list