From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7360 invoked by alias); 15 Sep 2015 14:19:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 7348 invoked by uid 89); 15 Sep 2015 14:19:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Sep 2015 14:19:06 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 52E9E757B5AEA for ; Tue, 15 Sep 2015 15:19:01 +0100 (IST) Received: from hhmail02.hh.imgtec.org (10.100.10.20) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 15 Sep 2015 15:19:03 +0100 Received: from hhmail02.hh.imgtec.org ([::1]) by hhmail02.hh.imgtec.org ([::1]) with mapi id 14.03.0235.001; Tue, 15 Sep 2015 15:19:03 +0100 From: Simon Dardis To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] Target hook for disabling the delay slot filler. Date: Tue, 15 Sep 2015 14:25:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg01082.txt.bz2 Hello all, This patch adds a target hook for disabling the eager delay slot filler whi= ch when disabled can give better code. No new regressions. Ok to commit? Thanks, Simon gcc/ * target.def (use_eager_delay_filler_p): New hook for selectively disabling eager delay slot filler. * reorg.c (dbr_schedule): Use the new hook. * config/mips/mips.c (mips_use_eager_delay_filler_p): New static function. (TARGET_USE_EAGER_DELAY_FILLER_P): Define. * doc/tm.texi.in: Add placeholder for new hook. * doc/tm.texi: Regenerate. gcc/testsuite/ * gcc.target/mips/ds-schedule-1.c: New file. * gcc.target/mips/ds-schedule-2.c: Likewise. Index: gcc/config/mips/mips.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/config/mips/mips.c (revision 227676) +++ gcc/config/mips/mips.c (working copy) @@ -14425,6 +14425,14 @@ return cached_can_issue_more; } =20 +/* Implement USE_EAGER_DELAY_FILLER. */ + +static bool +mips_use_eager_delay_filler_p () +{ + return TARGET_CB_NEVER; +} + /* Update round-robin counters for ALU1/2 and FALU1/2. */ =20 static void @@ -19982,6 +19990,9 @@ #undef TARGET_IN_SMALL_DATA_P #define TARGET_IN_SMALL_DATA_P mips_in_small_data_p =20 +#undef TARGET_USE_EAGER_DELAY_FILLER_P +#define TARGET_USE_EAGER_DELAY_FILLER_P mips_use_eager_delay_filler_p + #undef TARGET_MACHINE_DEPENDENT_REORG #define TARGET_MACHINE_DEPENDENT_REORG mips_reorg =20 Index: gcc/doc/tm.texi =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/doc/tm.texi (revision 227676) +++ gcc/doc/tm.texi (working copy) @@ -10949,6 +10949,15 @@ definition is null. @end deftypefn =20 +@deftypefn {Target Hook} bool TARGET_USE_EAGER_DELAY_FILLER_P (void) +This predicate controls the use of the eager delay slot filler. Targets +such as certain MIPS architectures possess both branches with and without +delay slots. As the eager delay slot filler can increase code size, +disabling it is beneficial when ordinary branches are available. Use of +delay slot branches filled using the basic filler is often still desirable +as the delay slot can hide a pipeline bubble. +@end deftypefn + @deftypefn {Target Hook} void TARGET_INIT_BUILTINS (void) Define this hook if you have any machine-specific built-in functions that need to be defined. It should be a function that performs the Index: gcc/doc/tm.texi.in =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/doc/tm.texi.in (revision 227676) +++ gcc/doc/tm.texi.in (working copy) @@ -7985,6 +7985,8 @@ =20 @hook TARGET_MACHINE_DEPENDENT_REORG =20 +@hook TARGET_USE_EAGER_DELAY_FILLER_P + @hook TARGET_INIT_BUILTINS =20 @hook TARGET_BUILTIN_DECL Index: gcc/reorg.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/reorg.c (revision 227676) +++ gcc/reorg.c (working copy) @@ -3793,7 +3793,8 @@ { fill_simple_delay_slots (1); fill_simple_delay_slots (0); - fill_eager_delay_slots (); + if (targetm.use_eager_delay_filler_p ()) + fill_eager_delay_slots (); relax_delay_slots (first); } =20 Index: gcc/target.def =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/target.def (revision 227676) +++ gcc/target.def (working copy) @@ -3618,6 +3618,17 @@ definition is null.", void, (void), NULL) =20 +/* Control of eager delay slot filling in delayed-branch scheduling. */ +DEFHOOK +(use_eager_delay_filler_p, + "This predicate controls the use of the eager delay slot filler. Targets= \n\ +such as certain MIPS architectures possess both branches with and without\= n\ +delay slots. As the eager delay slot filler can increase code size,\n\ +disabling it is beneficial when ordinary branches are available. Use of\n\ +delay slot branches filled using the basic filler is often still desirable= \n\ +as the delay slot can hide a pipeline bubble.", bool, (void), + hook_bool_void_true) + /* Create the __builtin_va_list type. */ DEFHOOK (build_builtin_va_list, Index: gcc/testsuite/gcc.target/mips/ds-schedule-1.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/testsuite/gcc.target/mips/ds-schedule-1.c (revision 0) +++ gcc/testsuite/gcc.target/mips/ds-schedule-1.c (working copy) @@ -0,0 +1,29 @@ +/* { dg-options "isa_rev>=3D6 -mcompact-branches=3Doptimal -mno-abicalls -= G4" } */ +/* { dg-final { scan-assembler-not "bne\t" } } */ +/* { dg-final { scan-assembler-not "beq\t" } } */ +/* { dg-final { scan-assembler-times "\\(foo\\)" 1 } } */ + +/* Test that when compact branches are used, that a compact branch is + produced in the case where code expansion would have occurred if a + delay slot branch would have be used. 'foo' should only be + referenced once in the program text. */ + +struct list +{ + struct list *next; + int element; +}; + +struct list *gr; + +int foo; + +extern void t (int, int, int*); + +void +f (struct list **ptr) +{ + if (gr) + *ptr =3D gr->next; + t (1, foo, &gr->element); +} Index: gcc/testsuite/gcc.target/mips/ds-schedule-2.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/testsuite/gcc.target/mips/ds-schedule-2.c (revision 0) +++ gcc/testsuite/gcc.target/mips/ds-schedule-2.c (working copy) @@ -0,0 +1,28 @@ +/* { dg-options "-mcompact-branches=3Dnever -mno-abicalls -G4" } */ +/* { dg-skip-if "code quality test" { *-*-* } { "-O0" "-O1" "-Os" } { "" }= } */ +/* { dg-final { scan-assembler "beq.*\n\tlw" } } */ +/* { dg-final { scan-assembler-times "\\(foo\\)" 2 } } */ + +/* Test that when compact branches are explicitly disabled, that a non-com= pact + branch is produced. 'foo' should be referenced twice in the program tex= t as the + eager delay slot filler will duplicate the load of foo. */ + +struct list +{ + struct list *next; + int element; +}; + +struct list *gr; + +int foo; + +extern void t (int, int, int*); + +void +f (struct list **ptr) +{ + if (gr) + *ptr =3D gr->next; + t (1, foo, &gr->element); +}