The code generated for a ppc32 for the 1 line function f below is incorrect. Not that it should matter but this is a cross compiler, built with cross-tool. typedef struct { unsigned char c; unsigned int i:24; } e_t; f(e_t *p) { p->i<<= 8; } #include <stdio.h> int main(int argc, char *argv[]) { e_t x = { .c='a', .i=0x12345 }; f(&x); printf("(0x12345 << 8 ) & 0xffffff = %x\n", x.i); } Compiled with "-O". The output is (0x12345 << 8 ) & 0xffffff = 234561 The bottom 8 bits should be zero, not the contents of x.c. If one comments out the driver function, so all that you are left with is the f function, one gets the following assembler. I have added pseudo-C comments. .file "t.c" .section ".text" .align 2 .globl f .type f, @function f: lwz 9,0(3) ;; r9 = *p mr 0,9 ;; r0 = r9 rlwimi 0,9,8,8,31 ;; low24(r0) = low24(rotate8(r9)) ****** Wrong stw 0,0(3) ;; *p = r0 blr ;; return .size f, .-f .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.4.6" gcc2.95 generates the correct code, and answer (0x12345 << 8 ) & 0xffffff = 234500
Cannot reproduce this problem on PPC32 with gcc-4.2.0. The result is with all -Ox correct: 234500
Not reproducible, and gcc 3.4 is not supported anymore.
Subject: RE: gcc3.4.6 generates incorrect ppc32 code for combination of bitfields and shifts Whilst I am not complaining about 3.4 not being supported, I think it is a pretty poor show that you are not able to reproduce it. Did anyone even try? > -----Original Message----- > From: steven at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org] > Sent: Friday, February 06, 2009 1:16 PM > To: Icarus Sparry > Subject: [Bug middle-end/30595] gcc3.4.6 generates incorrect > ppc32 code for combination of bitfields and shifts > > > > ------- Comment #2 from steven at gcc dot gnu dot org > 2009-02-06 21:15 ------- Not reproducible, and gcc 3.4 is not > supported anymore. > > > -- > > steven at gcc dot gnu dot org changed: > > What |Removed |Added > -------------------------------------------------------------- > -------------- > Status|UNCONFIRMED |RESOLVED > Resolution| |WONTFIX > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30595 > > ------- You are receiving this mail because: ------- You > reported the bug, or are watching the reporter. >
Works with: gcc version 4.4.0 20090116 (experimental) [trunk revision 143448] (GCC)
Subject: Re: gcc3.4.6 generates incorrect ppc32 code for combination of bitfields and shifts > Whilst I am not complaining about 3.4 not being supported, I think it is > a pretty poor show that you are not able to reproduce it. Did anyone > even try? Yes, there actually was a duplicate bug report for this, iirc. We don't do a good communication job in our bug bashing efforts. It is, well, just hard, with so many bugs and so few people who are willing to wade through the long list of bug reports. I'm sorry about that...