* the complete command line that triggers the bug; mips64-none-elf-gcc bar.c -v -O0 -G0 -mips1 -mabi=32 -S -v * The resultant code works incorrectly because there is no NOP between the following commands: lw $2,%lo(lastc.1)($2) xor $2,$3,$2 * the preprocessed file (*.i*) that triggers the bug, generated by adding -save-temps to the complete compilation command, or, in the case of a bug report for the GNAT front end, a complete set of source files (see below). void bar (int n, int c) { static int lastn = -1, lastc = -1; if (lastn != n) { if (lastc != lastn) abort (); lastc = 0; lastn = n; } if (c != (char) (lastc ^ (n << 3))) abort (); lastc++; } * The resultant assembler code .file 1 "bar.c" .section .mdebug.abi32 .previous .data .align 2 .type lastn.0, @object .size lastn.0, 4 lastn.0: .word -1 .align 2 .type lastc.1, @object .size lastc.1, 4 lastc.1: .word -1 .text .align 2 .globl bar .ent bar bar: .frame $fp,24,$31 # vars= 0, regs= 2/0, args= 16, gp= 0 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-24 sw $31,20($sp) sw $fp,16($sp) move $fp,$sp sw $4,24($fp) sw $5,28($fp) lui $2,%hi(lastn.0) lw $3,%lo(lastn.0)($2) lw $2,24($fp) nop beq $3,$2,$L2 nop lui $2,%hi(lastc.1) lui $3,%hi(lastn.0) lw $4,%lo(lastc.1)($2) lw $2,%lo(lastn.0)($3) nop beq $4,$2,$L3 nop jal abort nop $L3: lui $2,%hi(lastc.1) sw $0,%lo(lastc.1)($2) lui $3,%hi(lastn.0) lw $2,24($fp) nop sw $2,%lo(lastn.0)($3) $L2: lw $2,24($fp) nop sll $3,$2,3 lui $2,%hi(lastc.1) lw $2,%lo(lastc.1)($2) xor $2,$3,$2 sll $3,$2,24 sra $3,$3,24 lw $2,28($fp) nop beq $3,$2,$L4 nop jal abort nop $L4: lui $3,%hi(lastc.1) lui $2,%hi(lastc.1) lw $2,%lo(lastc.1)($2) nop addiu $2,$2,1 sw $2,%lo(lastc.1)($3) move $sp,$fp lw $31,20($sp) lw $fp,16($sp) addiu $sp,$sp,24 j $31 nop .set macro .set reorder .end bar
Confirmed. Seems to be caused by some no-op moves that get deleted after machine_dependent_reorg.
Subject: Bug 15869 CVSROOT: /cvs/gcc Module name: gcc Changes by: rsandifo@gcc.gnu.org 2004-06-22 21:28:06 Modified files: gcc : ChangeLog gcc/config/mips: mips.c Log message: PR target/15869 * config/mips/mips.c (mips_avoid_hazards): Call split_all_insns_noflow. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4081&r2=2.4082 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.c.diff?cvsroot=gcc&r1=1.418&r2=1.419
Patch applied to HEAD: http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01798.html CC'ing Mark since this is a 3.4 regression.
Adding a target milestone of 3.4.2 is probably just a formality, and I seem to remember only Mark can set it to 3.4.1, but for avoidance of doubt...I'd really like to see this go into 3.4.1 if possible. It's entirely contained within the MIPS backend, so there should be no risk to other targets. And I think the patch is low risk for MIPS too.
I think this one needs a bit more testing; apply it after 3.4.1 is out.
Subject: Re: [3.4 Regression] No NOP after LW (with -mips1 -O0) "mmitchel at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: > ------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-06-23 06:55 ------- > I think this one needs a bit more testing; apply it after 3.4.1 is out. Sorry to be pushy, but from whom? I don't think anyone other than me & David Billinghurst are testing CVS sources at the moment. If you're thinking about Maciej's offer to test on r3000 h/w: well, that's going to be useful to see if there are more cases we're missing. But it's easy to verify (by looking at assembler sources) that the instance reported in the PR has been fixed. And knowing the code (and having written it myself ;) I don't think it can introduce _more_ problems of the same kind. Could I ask you to reconsider? (Don't worry, if you say no, I won't ask again.) Richard
Subject: Re: [3.4 Regression] No NOP after LW (with -mips1 -O0) rsandifo at redhat dot com wrote: >------- Additional Comments From rsandifo at redhat dot com 2004-06-23 07:05 ------- >Subject: Re: [3.4 Regression] No NOP after LW (with > -mips1 -O0) > >"mmitchel at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: > > >>------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-06-23 06:55 ------- >>I think this one needs a bit more testing; apply it after 3.4.1 is out. >> >> > >Sorry to be pushy, but from whom? I don't think anyone other than me & >David Billinghurst are testing CVS sources at the moment. > > From whomever is using the MIPS toolchains, in general. :-) Since this is on the mainline, people will be banging away on it, and if there are problems, they'll likely find them. These things are judgement calls -- it's always hard to justify them precisely one way or the other. My instincts with this patch are a little different from yours; I feel like it might cause problems, not because it's wrong per se, but because it might trigger some other weirdness. If it had gone in a month ago, I'd feel different.
Subject: Re: [3.4 Regression] No NOP after LW (with -mips1 -O0) "mark at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org> writes: > These things are judgement calls -- it's always hard to justify them > precisely one way or the other. My instincts with this patch are a > little different from yours; I feel like it might cause problems, not > because it's wrong per se, but because it might trigger some other > weirdness. If it had gone in a month ago, I'd feel different. Fair enough ;) 3.4.2 it is.
Subject: Bug 15869 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: rsandifo@gcc.gnu.org 2004-07-07 06:28:20 Modified files: gcc : ChangeLog gcc/config/mips: mips.c Log message: PR target/15869 * config/mips/mips.c (mips_avoid_hazards): Call split_all_insns_noflow. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.533&r2=2.2326.2.534 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.362.4.13&r2=1.362.4.14
Fixed for 3.4.2.