public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Hans-Joachim Widmaier <hjwidmai@foxboro.com>
To: gcc-gnats@gcc.gnu.org
Subject: target/7462: Bad code for unalign access on PPC
Date: Wed, 31 Jul 2002 22:56:00 -0000	[thread overview]
Message-ID: <200208010544.g715i6o14828@linux1> (raw)


>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:


                 reply	other threads:[~2002-08-01  5:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200208010544.g715i6o14828@linux1 \
    --to=hjwidmai@foxboro.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).