This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Athlon specific optimization
> On Mon, Jul 15, 2002 at 04:38:31PM +0200, Jan Hubicka wrote:
> > + At the moment we implement single transformation: AMD Athlon works faster
> > + when RET is not destination of conditional jump or directly preceeded
> > + by other jump instruction. We avoid the penalty by inserting NOP just
> > + before the RET instructions in such cases. */
>
> Hmm. Interesting.
:)
>
> > + FOR_EACH_BB (bb)
>
> You do not need to work this hard. Work backwards from EXIT.
Good idea. OK now?
Wed Jul 10 15:01:28 CEST 2002 Jan Hubicka <jh@suse.cz>
* i386.h (MACHINE_DEPENDENT_REORG): New macro.
* i386.c (x86_machine_dependent_reorg): New function.
* i386-protos.h (x86_machine_dependent_reorg): Declare.
Index: i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.432
diff -c -3 -p -r1.432 i386.c
*** i386.c 15 Jul 2002 06:57:36 -0000 1.432
--- i386.c 16 Jul 2002 07:59:51 -0000
*************** x86_field_alignment (field, computed)
*** 13678,13681 ****
--- 13678,13726 ----
return computed;
}
+ /* Implement machine specific optimizations.
+ At the moment we implement single transformation: AMD Athlon works faster
+ when RET is not destination of conditional jump or directly preceeded
+ by other jump instruction. We avoid the penalty by inserting NOP just
+ before the RET instructions in such cases. */
+ void
+ x86_machine_dependent_reorg (first)
+ rtx first ATTRIBUTE_UNUSED;
+ {
+ edge e;
+
+ if (!TARGET_ATHLON || !optimize || optimize_size)
+ return;
+ for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+ {
+ basic_block bb = e->src;
+ rtx ret = bb->end;
+ rtx prev;
+ bool insert = false;
+
+ if (GET_CODE (ret) != JUMP_INSN || GET_CODE (PATTERN (ret)) != RETURN)
+ continue;
+ if (!maybe_hot_bb_p (bb))
+ continue;
+ prev = prev_nonnote_insn (ret);
+ if (prev && GET_CODE (prev) == CODE_LABEL)
+ {
+ edge e;
+ for (e = bb->pred; e; e = e->pred_next)
+ if (EDGE_FREQUENCY (e) && e->src->index > 0
+ && !(e->flags & EDGE_FALLTHRU))
+ insert = 1;
+ }
+ if (!insert)
+ {
+ prev = prev_real_insn (ret);
+ if (prev && GET_CODE (prev) == JUMP_INSN
+ && any_condjump_p (prev))
+ insert = 1;
+ }
+ if (insert)
+ emit_insn_before (gen_nop (), ret);
+ }
+ }
+
#include "gt-i386.h"