15869 – [3.4 Regression] No NOP after LW (with -mips1 -O0) (original) (raw)
| * 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,2,%lo(lastc.1)(2,2) xor 2,2,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,fp,24,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,sp,sp,-24 sw 31,20(31,20(31,20(sp) sw fp,16(fp,16(fp,16(sp) move fp,fp,fp,sp sw 4,24(4,24(4,24(fp) sw 5,28(5,28(5,28(fp) lui 2,2,%hi(lastn.0) lw 2,3,%lo(lastn.0)($2) lw 2,24(2,24(2,24(fp) nop beq 3,3,3,2,$L2 nop lui 2,2,%hi(lastc.1) lui 2,3,%hi(lastn.0) lw 4,4,%lo(lastc.1)(4,2) lw 2,2,%lo(lastn.0)(2,3) nop beq 4,4,4,2,$L3 nop jal abort nop L3:luiL3: lui L3:lui2,%hi(lastc.1) sw 0,0,%lo(lastc.1)(0,2) lui 3,3,%hi(lastn.0) lw 3,2,24($fp) nop sw 2,2,%lo(lastn.0)(2,3) L2:lwL2: lw L2:lw2,24($fp) nop sll 3,3,3,2,3 lui 2,2,%hi(lastc.1) lw 2,2,%lo(lastc.1)($2) xor 2,2,2,3,$2 sll 3,3,3,2,24 sra 3,3,3,3,24 lw 2,28(2,28(2,28(fp) nop beq 3,3,3,2,$L4 nop jal abort nop L4:luiL4: lui L4:lui3,%hi(lastc.1) lui 2,2,%hi(lastc.1) lw 2,2,%lo(lastc.1)($2) nop addiu 2,2,2,2,1 sw 2,2,%lo(lastc.1)(2,3) move sp,sp,sp,fp lw 31,20(31,20(31,20(sp) lw fp,16(fp,16(fp,16(sp) addiu sp,sp,sp,sp,24 j $31 nop .set macro .set reorder .end bar Comment 1 Richard Sandiford 2004-06-22 08🔞57 UTC Confirmed. Seems to be caused by some no-op moves that get deleted after machine_dependent_reorg. Comment 4 Richard Sandiford 2004-06-23 06:46:45 UTC 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. Comment 5 Mark Mitchell 2004-06-23 06:55:17 UTC I think this one needs a bit more testing; apply it after 3.4.1 is out. Comment 6 Richard Sandiford 2004-06-23 07:05:29 UTC 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 Comment 7 Mark Mitchell 2004-06-23 15:54:59 UTC 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. Comment 8 Richard Sandiford 2004-06-23 16:38:46 UTC 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. Comment 10 Richard Sandiford 2004-07-07 06:33:04 UTC Fixed for 3.4.2. | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |