This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
target/7462: Bad code for unalign access on PPC
- From: Hans-Joachim Widmaier <hjwidmai at foxboro dot com>
- To: gcc-gnats at gcc dot gnu dot org
- Date: Thu, 1 Aug 2002 07:44:06 +0200
- Subject: target/7462: Bad code for unalign access on PPC
- Reply-to: hjwidmai at foxboro dot com
>Number: 7462
>Category: target
>Synopsis: Bad code for unalign access on PPC
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: pessimizes-code
>Submitter-Id: net
>Arrival-Date: Wed Jul 31 22:56:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.1.1
>Organization:
Foxboro Eckardt Development GmbH
>Environment:
System: Linux linux1 2.4.10-4GB #1 Tue Sep 25 12:33:54 GMT 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: powerpc-unknown-rtems
configured with: /pub/build/gcc-3.1.1/configure --host=i686-pc-linux-gnu --target=powerpc-rtems --disable-nls --disable-shared --enable-languages=c --with-newlib --with-cpu=405 --enable-threads=rtems
>Description:
Unaligned accesses to short/long/float variables in memory generate code which does multiple
byte loads/stores with masking and shifting instead of 1 halfword/word load/store.
On processors that do not support unaligned accesses this is the correct thing
to do. For those that do, it is worse than just creating bad code: if the
variable happens to live in a little-endian memory region it will not be swapped and
therefore be invalid.
>How-To-Repeat:
The code was compiled with: powerpc-rtems-gcc -fallow-single-precision -mno-strict-align -fsingle-precision-constant -mcpu=405 -mtune=405 -O2 -c align.c
# 1 "align.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "align.c"
#pragma pack(1)
struct atest {
char b;
float f;
long l;
} ATest;
# 26 "align.c"
void bad(void)
{
ATest.f *= 6.5;
ATest.l *= 6;
}
void ok(void)
{
*&ATest.f *= 6.5;
*&ATest.l *= 6;
}
>Fix:
The split-up into byte accesses is not done when the memory is accessed via a pointer as
in function ok() above.
>Release-Note:
>Audit-Trail:
>Unformatted: