This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: pseudo conditional traps for ix86
- To: Greg McGary <greg at mcgary dot org>
- Subject: Re: PATCH: pseudo conditional traps for ix86
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Mon, 28 Aug 2000 19:40:24 -0700 (PDT)
- cc: gcc-patches at gcc dot gnu dot org
On 28 Aug 2000, Greg McGary wrote:
>
> That's an excellent idea. We can easily mutate an arbitrary condition
> into overflow like so:
>
> setCC REG ; REG = 1 if CC holds, 0 otherwise
> addl $0x7fffffff, REG ; OF now set if CC holds
> into ; boom
Good. Well, actually, it would have to be
setCC REG
addb $0x7f, REG
into
because setcc only sets the low eight bits, but that just makes it easier
anyway (smaller instruction size and all that).
I don't know what comparisons the bounds checking stuff actually wants to
use, but I assume it's the unsigned compare that is the most common. In
which case the above would be the normal case. Too bad.
NOTE! One thing to check is definitely how fast intel is at doing
conditional "into"'s. Intel CPU's tend to slow down quite a bit for
serializing instructions, and maybe an "into" is serializing even when it
doesn't actually trigger. So the above might be much slower than it looks.
The only way to test would be to write a small test-program.
Anyway, code-size and the above performance worry makes me suspect your
original approach may have been better after all - because I don't think
you'll see the "use the 'overflow' flag natively" case very often.
Oh, well.
Linus
PS. You might try out a small modification on your original case: just
emit a
"j%c0 __internal_gcc_trap"
inside the code directly, and add a small function to libgcc that just
does
__internal_gcc_trap:
int $4
and nothing more. It should be better for the branch predictor (forward
never-taken case), and probably nicer on prefetching. But I don't think it
matters all that much.