This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: disabling branch probability guessing (patch) [another patch]
>>>>> "Andi" == Andi Kleen <ak@suse.de> writes:
> On Tue, Jan 16, 2001 at 08:55:36AM -0800, Joe Buck wrote:
>> Andi Kleen writes:
>> > Cool. This is useful for the linux kernel too. I found out that the
>> > prediction guessing undoes some of the carefully crafted goto woods
>> > to keep fast paths jumpless.
>>
>> I'm not sure that this is really the right solution. In all examples
>> in which I've seen gotos used by good programmers, the goto is an
>> exceptional condition and should be predicted not-taken. Can't we
>> just flag branches originally entered as gotos?
> I agree that that would be a good heuristic. Assume goto as not taken.
Alright. I did some playing around to predict gotos as not taken
(patch below). It seems to work pretty good.
I have a few questions though...
I tested this on a couple of x86 bootstraps. My "benchmark" was
running a freshly built gcc (with and without the new prediction)
against "gcc/stmt.i" and timing the compilations.
The patch below speeds things up by a few nanoseconds-- if that. The
unix "time" doesn't seem to be very good for benchmarks.
What program can I use to time other programs?
What's a good way of doing benchmarks?
Is there some kind free benchmarking program I can use?
What's a good architecture to test this out-- preferable one with a
high penalty for missed branch predictions?
And finally, is the patch below correct? I deduct that gotos are
jumps with text labels.
Cheers.
Aldy
Index: predict.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/predict.c,v
retrieving revision 1.13
diff -c -r1.13 predict.c
*** predict.c 2000/05/19 22:27:26 1.13
--- predict.c 2001/01/20 06:47:42
***************
*** 111,117 ****
for (i = 0; i < n_basic_blocks - 1; i++)
{
rtx last_insn = BLOCK_END (i);
! rtx cond, earliest;
int prob;
edge e;
--- 111,117 ----
for (i = 0; i < n_basic_blocks - 1; i++)
{
rtx last_insn = BLOCK_END (i);
! rtx cond, earliest, label;
int prob;
edge e;
***************
*** 121,126 ****
--- 121,135 ----
if (find_reg_note (last_insn, REG_BR_PROB, 0))
continue;
+
+ /* Predict gotos as false. */
+ label = JUMP_LABEL (last_insn);
+ if (GET_CODE (label) == CODE_LABEL
+ && XSTR (label, 6))
+ {
+ prob = PROB_UNLIKELY;
+ goto emitnote;
+ }
cond = get_condition (last_insn, &earliest);
if (! cond)