This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [committed] PR 51931: force non-MIPS16ness for long-branch tests (NOW RFA: MIPS16 Long Branch Patch)



> -----Original Message-----
> From: Chung-Lin Tang [mailto:cltang@codesourcery.com]
> Sent: Monday, January 30, 2012 4:36 AM
> To: gcc-patches@gcc.gnu.org; rdsandiford@googlemail.com
> Cc: Moore, Catherine
> Subject: Re: [committed] PR 51931: force non-MIPS16ness for long-branch tests
> 
> On 2012/1/22 06:33 PM, Richard Sandiford wrote:
> > The MIPS16 port has never handled long branches properly; see PR 51931
> > for the details.  It isn't easy to xfail MIPS16-specific problems at
> > the dejagnu level because of -mflip-mips16, so the patch below forces
> > a nomips16 attribute instead.
> >
> > Tested on mips64-linux-gnu and applied.
> >
> > Richard
> 
> CCing Catherine, I think we have a fix for this?
> 

I do have a patch.   It's a heuristic and will not work in all instances, but it does allow many additional programs to successfully compile.  For example, this scheme allowed me to build glibc in MIPS16-mode for a MIPS-Linux toolchain.  

The patch causes reorg to examine mips16 branches.  For branches that are out-of-range, reorg will look for branches to the same target.  If that branch is in range, the destination of the original branch becomes the new branch.  If branches to the same target do not exist, then reorg will search for barriers that are in range and insert label+ branch at the barrier.

Of the test cases mentioned in the bug report, gcc.c-torture/compile/20001226-1.c still fails due to a lack of barriers in the instruction stream.  g++.dg/opt/longbranch1.C will pass.

I've set off a test run with my patch applied against mainline.   In the meantime, here's the patch.  Richard, what do you think?

Catherine

2012-01-30  Catherine Moore  <clm@codesourcery.com>

        gcc/
        * config/mips/mips.c (WALK_INSNS): New macro.
        (OK_FOR_MIPS16_BRANCH_OFFSET): New macro.
        (mips16_count_matching_branches): New function.
        (walk_insns_forward): New function.
        (walk_insns_reverse): New function.
        (mips16_update_branch_info): New function.
        (mips16_zero_branch_info): New function.
        (mips16_check_branches): New function.
        (mips_reorg_process_instructions): Call mips16_check_branches.
        * config/mips.h (mips16_branch_info_t): New typedef.

Attachment: mips16-long-br.txt
Description: mips16-long-br.txt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]