Bug 30595 - gcc3.4.6 generates incorrect ppc32 code for combination of bitfields and shifts
Summary: gcc3.4.6 generates incorrect ppc32 code for combination of bitfields and shifts
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 3.4.6
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-26 02:32 UTC by Icarus Sparry
Modified: 2009-02-06 21:31 UTC (History)
2 users (show)

See Also:
Host: i686-host_pc-linux-gnu
Target: powerpc-unknown-linux-gnu
Build: i686-host_pc-linux-gnu
Known to work: 4.2.0
Known to fail: 4.0.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Icarus Sparry 2007-01-26 02:32:19 UTC
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
Comment 1 Clemens Koller 2007-07-04 10:34:45 UTC
Cannot reproduce this problem on PPC32 with gcc-4.2.0. The result is
with all -Ox correct: 234500
Comment 2 Steven Bosscher 2009-02-06 21:15:34 UTC
Not reproducible, and gcc 3.4 is not supported anymore.
Comment 3 Icarus Sparry 2009-02-06 21:25:17 UTC
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.
> 
Comment 4 Andrew Pinski 2009-02-06 21:31:48 UTC
Works with:
gcc version 4.4.0 20090116 (experimental) [trunk revision 143448] (GCC) 

Comment 5 stevenb.gcc@gmail.com 2009-02-06 22:40:55 UTC
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...