This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Need advice on bounds checking approaches
- To: law at cygnus dot com
- Subject: Re: Need advice on bounds checking approaches
- From: Greg McGary <gkm at eng dot ascend dot com>
- Date: 28 Mar 2000 10:27:52 -0700
- Cc: Geoff Keating <geoffk at cygnus dot com>, gcc at gcc dot gnu dot org
- References: <9365.954255482@upchuck>
Jeffrey A Law <law@cygnus.com> writes:
> Is there any advantage to not always emitting the high/low bounds checks
> separately?
For i960 there's a small advantage that if you emit checks together,
you can use concmp and save one instruction ("cmpo; concmpo; fault"
vs. "cmpo; fault; cmpo; fault"). Big deal...
For i386, if you check both at once, you can use the `bound'
instruction, which is slower, but very compact.
In summary, there will be some small space advantage for any target
that has special instructions that support bounds checking. For
multiple-issue CPUs, the space advantage will come at the expense of
runtime, because the checks would likely run faster if they were
broken apart to improve scheduling. It should be easy enough to
implement each and benchmark to quantify the difference, or even to
implement both, and choose at compile time based on the value of
`optimize_size'.
Greg