Re: Use of unaligned load/stores by compilers

albaugh@agames.com (Mike Albaugh)
1 Feb 1998 14:28:46 -0500

          From comp.compilers

Related articles
[3 earlier articles]
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: albaugh@agames.com (Mike Albaugh)
Newsgroups: comp.compilers
Date: 1 Feb 1998 14:28:46 -0500
Organization: Atari Games Corporation
References: 98-01-099 98-01-105 98-01-114 98-01-119
Keywords: architecture, practice

Reid Tatge (reid@micro.ti.com) wrote:
[ familiar story of bad assumptions on the part of programmers]


: My experience with adding support for misaligned pointers: not
: particularly hard to do, but very inefficient. Every pointer
: reference for which analysis or declaration cannot guarantee proper
: alignment is subject to significant bloat - effectively loading each
: byte, shifting, ORing. For reading a 4-byte value its something like
: 10 operations. Writes are correspondingly worse. Good candidates for
: going out-of-line.


It's worse than that. Every once in a while, I get into some
sort of crusade mode and reply to each and every (several a month)
posting of the question "How can I get compiler xxx to pack
structures", with a comment on why it would be a much better idea to
fix the code. If the poster seems to have a glimmer of a clue, I ask
them to consider what happens when they pass a pointer to a
mis-aligned int or long to a library routine (or worse, a system
call). Should the library, right on down through the kernel, be hacked
to always pick up every multi-byte entity one byte at a time? Some of
them get it. Others just keep on writing desktop apps :-)


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


"You know how stupid the average person is, right? Well,
half of them are dumber than _that_". :-)


: [I think this is the 1990s equivalent of the old observation that a
: determined programmer can write a Fortran program in any language. -John]


Actually, some alleged C code that I inherited showed that a
_truly_ determined programmer can write _BASIC_ in any language. No
subroutine ever took parameters or returned a result. All was done via
global variables. And I do mean "global". Variables were almost never
declared in the same file as the (often only) code that used
them. Laugh while you can. Those programmers left for a position
programming semiconductor test equipment.


Mike
| albaugh@agames.com
--


Post a followup to this message

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