This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13511] Problem with compiler optimization -o2
- From: "osoentgen at lucent dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jan 2004 12:43:56 -0000
- Subject: [Bug c++/13511] Problem with compiler optimization -o2
- References: <20031230104215.13511.osoentgen@lucent.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From osoentgen at lucent dot com 2004-01-05 12:43 -------
Subject: RE: Problem with compiler optimization -o2
Andrew,
Now with commented assembler code.
'*Frameptr >> 8' leads to missing pointer increment:
void test ()
{
char *Frameptr = (char *) buffer;
char *CEmsgArray = (char *)buffer2;
100000: 3d 40 00 10 lis r10,16 Prepare
CEmsgArray address
100004: 39 4a 00 98 addi r10,r10,152 CEmsgArray
addr has been loaded into R10
Frameptr++;
{ CEmsgArray [12 ] = (char)( *Frameptr >> 8 ); CEmsgArray [13 ]
= (char)( *Frameptr ); } ;
100008: 38 00 00 00 li r0,0 Shift by 8
is always zero
10000c: 3d 60 00 10 lis r11,16 Prepare
Frameptr address
100010: 98 0a 00 0c stb r0,12(r10)
CEmsgArray[12] is being assigned (OK)
100014: 39 6b 00 34 addi r11,r11,52 Frameptr
addr has been loaded into R11
100018: 88 0b 00 00 lbz r0,0(r11) *Frameptr
10001c: 98 0a 00 0d stb r0,13(r10)
CEmsgArray[13] is being assigned (WRONG!!!)
CEmsgArray[10]=(char) (*Frameptr);
100020: 89 2b 00 00 lbz r9,0(r11) *Frameptr
100024: 99 2a 00 0a stb r9,10(r10)
CEmsgArray[10] is being assigned (WRONG!!!)
CEmsgArray[11]=(char) (*Frameptr);
100028: 88 0b 00 00 lbz r0,0(r11) *Frameptr
10002c: 98 0a 00 0b stb r0,11(r10)
CEmsgArray[11] is being assigned (WRONG!!!)
100030: 4e 80 00 20 blr
=================
Example of good case (shift of 7):
void test ()
{
char *Frameptr = (char *) buffer;
100000: 3d 40 00 10 lis r10,16 Prepare
Frameptr address
100004: 39 4a 00 38 addi r10,r10,56 Frameptr
addr has been loaded into R10
char *CEmsgArray = (char *)buffer2;
Frameptr++;
{ CEmsgArray [12 ] = (char)( *Frameptr >> 7 ); CEmsgArray [13 ]
= (char)( *Frameptr ); } ;
100008: 8c 0a 00 01 lbzu r0,1(r10) Frameptr++
10000c: 3d 60 00 10 lis r11,16 Prepare
CEmsgArray address
100010: 39 6b 00 9c addi r11,r11,156 CEmsgArray
addr has been loaded into R11
100014: 54 00 c9 fe rlwinm r0,r0,25,7,31 >> 7
100018: 98 0b 00 0c stb r0,12(r11)
CEmsgArray[12] is being assigned (OK)
10001c: 89 2a 00 00 lbz r9,0(r10) *Frameptr
100020: 99 2b 00 0d stb r9,13(r11)
CEmsgArray[13] is being assigned (OK)
CEmsgArray[10]=(char) (*Frameptr);
100024: 88 0a 00 00 lbz r0,0(r10) *Frameptr
100028: 98 0b 00 0a stb r0,10(r11)
CEmsgArray[10] is being assigned (OK)
CEmsgArray[11]=(char) (*Frameptr);
10002c: 89 2a 00 00 lbz r9,0(r10) *Frameptr
100030: 99 2b 00 0b stb r9,11(r11)
CEmsgArray[11] is being assigned (OK)
100034: 4e 80 00 20 blr
Regards,
Olaf
-----Original Message-----
From: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org]
Sent: Dienstag, 30. Dezember 2003 16:36
To: osoentgen@lucent.com
Subject: [Bug c++/13511] Problem with compiler optimization -o2
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-12-30
15:35 -------
The relocations which are 0 in your output will show that the problem is
that you are not reading
the asm right:
-O1:
lis r9,ha16(_buffer2)
la r9,lo16(_buffer2)(r9)
lis r2,ha16(_buffer+1)
lbz r2,lo16(_buffer+1)(r2) <--- see the plus one
extsb r0,r2
srawi r0,r0,8
stb r0,12(r9)
stb r2,13(r9)
stb r2,10(r9)
stb r2,11(r9)
blr
-O2 (the same on the mainline).
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
Summary|Problem with compiler |Problem with compiler
|optimization -o2 |optimization -o2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13511
------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13511