All of lore.kernel.org
 help / color / mirror / Atom feed
From: mjn3@codepoet.org (Manuel Novoa III)
To: Robert de Bath <robert$@mayday.cix.co.uk>
Cc: Riley Williams <Riley@Williams.Name>,
	Linux-8086 <linux-8086@vger.kernel.org>
Subject: Re: More dev86 changes (0.16.5)
Date: Fri, 26 Jul 2002 09:12:33 -0600	[thread overview]
Message-ID: <20020726151233.GA20743@codepoet.org> (raw)
In-Reply-To: <6dc1a51a1aac3edd@mayday.cix.co.uk>

Robert,

On Fri, Jul 26, 2002 at 08:55:39AM +0100, Robert de Bath wrote:
> On Thu, 25 Jul 2002, Manuel Novoa III wrote:
> 
> > > One other thing I would like to see, which is an optimising measure more
> > > than anything: When bcc lays out the variables at any level, if it sorts
> > > them in descending order of size before laying them out, it will really
> > > minimise the number of padding bytes needed to ensure correct alignment.
> > > It is for this reason that when I am writing C code, I always list all
> > > of the variables in descending size order,
> >
> > Same here.  ;-)
> 
> This gains you nothing unless you are in the habit of using single byte

On occassion.  I know that on i386 I've seen gcc produce smaller code
when I declared some small counters or boolean values as char rather
than int.

> char values even then there's gotya ...
> 
> In 32bit mode int and long are the same size.
> In 16bit mode everything is aligned on 2 bytes boundries (including the stack).
> 
> In fact if you put them in _decending_ order of size you may actually
> be hurting the code because the BP register points at the top (highest
> memory address) of the current stack frame so the variables defined
> first have the smallest offsets and can probably be accessed using
> smaller (and possibly faster) instructions, however, this only applies
> if the offset exceeds 128 bytes.

Also relevant in structure defs if you're going to ref the structure via
a pointer.  Putting the most commonly referenced field first lets it be
referenced without an additional offset.  I think I saved about 100-200
bytes in the uClibc stdio code by doing that with the FILE struct.  Of
course, then you also may need to adjust the layout to avoid holes.

On the topic of bcc feature additions, things I've thought about are:
1) long long support since it is in C99 and (selfishly) since it would
   allow me to avoid rewriting a couple of uClibc functions.
2) wide char support, which of course, that brings up the question of
   whether or not wide chars be 16 bits (to save space) or 32 bits
   (for better compatibility) in 16 bit mode.

Also, I suppose we all wish for a better optimizer.  I'd love to not
have to resort to the "register char *" as loop counter hack anymore.

Manuel

  reply	other threads:[~2002-07-26 15:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-14 14:05 C compiler, assembler and linker Harry Kalogirou
2002-07-14 17:27 ` Manuel Novoa III
2002-07-15  6:07   ` Riley Williams
2002-07-15 17:02     ` Manuel Novoa III
2002-07-15 19:13       ` Riley Williams
2002-07-15 22:02         ` Manuel Novoa III
2002-07-16  6:27           ` Riley Williams
2002-07-17  1:31             ` Manuel Novoa III
2002-07-17  6:33               ` Riley Williams
2002-07-18 12:03                 ` Minix vs. ELKS Feher Tamas
2002-07-18 12:27                   ` Javier Sedano
2002-07-02 15:07                     ` (unknown) Miguel A. Bolanos
2002-07-18 13:40                   ` Minix vs. ELKS Alan Cox
2002-07-22 21:41                 ` C compiler, assembler and linker Robert de Bath
2002-07-23  8:16               ` Robert de Bath
2002-07-23 16:25                 ` Manuel Novoa III
2002-07-23 19:09                   ` Robert de Bath
2002-07-24 21:17         ` More dev86 changes (0.16.5) Robert de Bath
2002-07-24 22:02           ` Riley Williams
2002-07-25 15:42             ` Manuel Novoa III
2002-07-26  7:55               ` Robert de Bath
2002-07-26 15:12                 ` Manuel Novoa III [this message]
2002-07-26  8:22             ` Robert de Bath
2002-07-24 22:26           ` Paul Nasrat
2002-07-25 16:34             ` Manuel Novoa III
2002-07-22 23:26       ` C compiler, assembler and linker Robert de Bath
2002-07-23  0:34         ` Riley Williams
2002-07-23  0:58           ` Manuel Novoa III
2002-07-23  0:46         ` Manuel Novoa III

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=20020726151233.GA20743@codepoet.org \
    --to=mjn3@codepoet.org \
    --cc=Riley@Williams.Name \
    --cc=linux-8086@vger.kernel.org \
    --cc=robert$@mayday.cix.co.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.