Re: Use of unaligned load/stores by compilers

Tom Lane <tgl@netcom.com>
1 Feb 1998 14:22:29 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: Use of unaligned load/stores by compilers falan@inreach.com (Alan Fargusson) (1998-01-25)
Re: Use of unaligned load/stores by compilers corbett@lupa.Eng.Sun.COM (1998-01-25)
Re: Use of unaligned load/stores by compilers hrubin@stat.purdue.edu (1998-01-26)
Re: Use of unaligned load/stores by compilers - or doing things by hal henry@zoo.toronto.edu (Henry Spencer) (1998-01-26)
Re: Use of unaligned load/stores by compilers scott@basis.com (1998-01-30)
Re: Use of unaligned load/stores by compilers reid@micro.ti.com (Reid Tatge) (1998-01-30)
Re: Use of unaligned load/stores by compilers tgl@netcom.com (Tom Lane) (1998-02-01)
Re: Use of unaligned load/stores by compilers albaugh@agames.com (1998-02-01)
Re: Use of unaligned load/stores by compilers hrubin@stat.purdue.edu (1998-02-01)
Re: Use of unaligned load/stores by compilers dlmoore@ix.netcom.com (David L Moore) (1998-02-01)
Re: Use of unaligned load/stores by compilers fpeelo@portablesolutions.com (Frank Peelo) (1998-02-07)
| List of all articles for this month |

From: Tom Lane <tgl@netcom.com>
Newsgroups: comp.compilers
Date: 1 Feb 1998 14:22:29 -0500
Organization: Netcom Online Communications Services
References: 98-01-099 98-01-105 98-01-114 98-01-119
Keywords: architecture

Reid Tatge <reid@micro.ti.com> writes:
> Even in this X86-dominated world, it always surprises me how many
> programmers are completely unaware that there is such a thing as
> hardware enforced alignment of memory references. <Sigh>
>
> [I think this is the 1990s equivalent of the old observation that a
> determined programmer can write a Fortran program in any language. -John]


Perhaps you can take some comfort in the fact that said programmers
are paying a huge runtime price for their cluelessness, even on their
favorite X86 architecture. Misaligned reads and writes require
multiple memory cycles on the X86 series, too (at least on anything
with more than an 8-bit path to memory). In fact, my reference book
says that on 486 and up, a misaligned 32-bit read or write takes
*four* cycles, versus one cycle for aligned 32-bit data. It's only
because of Intel's unshakable dedication to backwards compatibility at
ANY cost that the feature is still there...


regards, tom lane
[The fact that it's so slow suggests that in fact they don't care all
that much. I was surprised to read that in the later IBM 390
machines, there's very little penalty for misaligned data. The cache
lines are quite long, so more often than not misaligned data is still
in a single line in which case there's no penalty, or it's in two
lines in which case there's in effect an extra load or store. The x86
takes a three cycle hit if misaligned data is in a single line and a
six to 12 cycle hit if it crosses into a second line. Intel's x86
optimization manual says it's an important performance issue, and the
Ppro and PII can count misaligned accesses as part of the internal
profiling features. -John




--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.