This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch - gas] MIPS: fix problem with mips16 delay branchoptimization.
- From: David Ung <davidu at mips dot com>
- To: binutils at sourceware dot org
- Date: Thu, 01 Sep 2005 15:29:44 +0100
- Subject: [patch - gas] MIPS: fix problem with mips16 delay branchoptimization.
This patch fixes a problem for Mips16 delay branch optimization when
swapping instructions, but the instructions belongs to different
fragments. This shows up in the GCC C regressions for mips16.
Schedule of variations:
mips-sim-idt32//-mips32/-mips16
...
FAIL: gcc.dg/compat/scalar-return-3 c_compat_x_tst.o-c_compat_y_tst.o execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t001 c_compat_x_tst.o-c_compat_y_tst.o execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t002 c_compat_x_tst.o-c_compat_y_tst.o execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t004 c_compat_x_tst.o-c_compat_y_tst.o execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t005 c_compat_x_tst.o-c_compat_y_tst.o execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t024 c_compat_x_tst.o-c_compat_y_tst.o execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t026 c_compat_x_tst.o-c_compat_y_tst.o execute
...
=== gcc Summary ===
# of expected passes 35866
# of unexpected failures 14
# of unexpected successes 1
# of expected failures 74
# of untested testcases 28
# of unsupported tests 532
/local/fsf-mainline/gcc/xgcc version 4.1.0 20050822 (experimental)
after applying the patch, I now get
=== gcc Summary ===
# of expected passes 35911
# of unexpected failures 7
# of unexpected successes 1
# of expected failures 74
# of untested testcases 28
# of unsupported tests 534
/local/fsf-mainline/gcc/xgcc version 4.1.0 20050826 (experimental)
ok for mainline?
David.
2005-09-01 David Ung <davidu@mips.com>
* config/tc-mips.c (append_insn): Correctly handle mips16 case
when the frags are different for the 2 instructions we want to
swap. If the lengths of the 2 instructions are not the same, we
won't do the swap but emit an nop.
Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.318
diff -c -p -b -r1.318 tc-mips.c
*** config/tc-mips.c 25 Aug 2005 18:17:36 -0000 1.318
--- config/tc-mips.c 1 Sep 2005 14:14:56 -0000
*************** append_insn (struct mips_cl_insn *ip, ex
*** 2698,2706 ****
struct mips_cl_insn delay = history[0];
if (mips_opts.mips16)
{
! know (delay.frag == ip->frag);
move_insn (ip, delay.frag, delay.where);
! move_insn (&delay, ip->frag, ip->where + insn_length (ip));
}
else if (relaxed_branch)
{
--- 2698,2719 ----
struct mips_cl_insn delay = history[0];
if (mips_opts.mips16)
{
! if (delay.frag == ip->frag)
! {
move_insn (ip, delay.frag, delay.where);
! move_insn (&delay, ip->frag, delay.where
! + insn_length (ip));
! }
! else if (insn_length (ip) == insn_length (&delay))
! {
! move_insn (&delay, ip->frag, ip->where);
! move_insn (ip, history[0].frag, history[0].where);
! }
! else
! {
! add_fixed_insn (NOP_INSN);
! delay = *NOP_INSN;
! }
}
else if (relaxed_branch)
{