This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH] Disable -mbranch-likely for -Os when targetting generic architecture
- From: Robert Suchanek <Robert dot Suchanek at imgtec dot com>
- To: "Moore, Catherine" <Catherine_Moore at mentor dot com>, Matthew Fortune <Matthew dot Fortune at imgtec dot com>, Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 24 May 2016 14:21:15 +0000
- Subject: RE: [PATCH] Disable -mbranch-likely for -Os when targetting generic architecture
- Authentication-results: sourceware.org; auth=none
- References: <B5E67142681B53468FAF6B7C31356562441B05F4 at hhmail02 dot hh dot imgtec dot org> <87y4h5iuwd dot fsf at googlemail dot com> <6D39441BF12EF246A7ABCE6654B0235321238501 at LEMAIL01 dot le dot imgtec dot org> <B5E67142681B53468FAF6B7C31356562441B53FB at hhmail02 dot hh dot imgtec dot org> <FD3DCEAC5B03E9408544A1E416F112420192CBEC39 at NA-MBX-04 dot mgc dot mentorg dot com>
Hi Catherine,
Apologies for the (very) late reply.
It appears that I never replied to the last message.
> > gcc/
> > * config/mips/mips-cpus.def: Replace PTF_AVOID_BRANCHLIKELY
> > with
> > PTF_AVOID_BRANCHLIKELY_ALWAYS for generic architecture and
> > with
> > PTF_AVOID_BRANCHLIKELY_SPEED for others.
> > (mips2, mips3, mips4): Add PTF_AVOID_BRANCHLIKELY_SIZE to tune
> > flags.
> > * config/mips/mips.c (mips_option_override): Enable the branch
> > likely
> > depending on the tune flags and optimization level.
> > * config/mips/mips.h (PTF_AVOID_BRANCHLIKELY): Remove.
> > (PTF_AVOID_BRANCHLIKELY_SPEED): Define.
> > (PTF_AVOID_BRANCHLIKELY_SIZE): Likewise.
> > (PTF_AVOID_BRANCHLIKELY_ALWAYS): Likewise.
> > ---
> > gcc/config/mips/mips-cpus.def | 56 +++++++++++++++++++++---------------
> > -------
> > gcc/config/mips/mips.c | 6 +++--
> > gcc/config/mips/mips.h | 20 ++++++++++++----
> > 3 files changed, 47 insertions(+), 35 deletions(-)
> >
> > a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 0e0ecf2..f8775c4
> > 100644
> > --- a/gcc/config/mips/mips.c
> > +++ b/gcc/config/mips/mips.c
> > @@ -17916,8 +17916,10 @@ mips_option_override (void)
> > if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0)
> > {
> > if (ISA_HAS_BRANCHLIKELY
> > - && (optimize_size
> > - || (mips_tune_info->tune_flags & PTF_AVOID_BRANCHLIKELY)
> > == 0))
> > + && ((optimize_size && (mips_tune_info->tune_flags
> > + & PTF_AVOID_BRANCHLIKELY_SIZE) == 0)
> > + || (!optimize_size && (mips_tune_info->tune_flags
> > + & PTF_AVOID_BRANCHLIKELY_SPEED) ==
> > 0)))
> > target_flags |= MASK_BRANCHLIKELY;
> > else
> > target_flags &= ~MASK_BRANCHLIKELY;
>
> Should this check be:
> Index: mips.c
> ===================================================================
> --- mips.c (revision 229138)
> +++ mips.c (working copy)
> @@ -17758,8 +17758,15 @@
> if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0)
> {
> if (ISA_HAS_BRANCHLIKELY
> - && (optimize_size
> - || (mips_tune_info->tune_flags & PTF_AVOID_BRANCHLIKELY) == 0))
> + && ((optimize_size
> + && (mips_tune_info->tune_flags
> + & PTF_AVOID_BRANCHLIKELY_SIZE) == 0)
> + || (!optimize_size
> + && optimize > 0
> + && ((mips_tune_info->tune_flags
> + & PTF_AVOID_BRANCHLIKELY_SPEED) == 0))
> + || (mips_tune_info->tune_flags
> + & PTF_AVOID_BRANCHLIKELY_ALWAYS) == 0))
> target_flags |= MASK_BRANCHLIKELY;
> else
> target_flags &= ~MASK_BRANCHLIKELY;
>
> Instead? I don't see a use of PTF_AVOID_BRANCH_ALWAYS in your patch, but it
> seems like it should be checked.
>
I did that on purpose at the time as the check looked redundant as it will be one
or the other. However, for easier reading and a potential redefinition of *_ALWAYS
e.g. to a unique value then the extra check is a must.
I'm happy to include this. Ok to commit with this change?
Regards,
Robert