On Tue, 31 Oct 2000, Ruslan Ermilov wrote:

> On Sat, Oct 28, 2000 at 04:13:46PM +1100, Bruce Evans wrote:
> > On Fri, 27 Oct 2000, Ruslan Ermilov wrote:
> > 
> > > On Fri, Oct 27, 2000 at 06:11:49PM +0300, Ruslan Ermilov wrote:
> > > > On Fri, Oct 27, 2000 at 07:34:06AM -0700, Mike Smith wrote:
> > > > > > +#ifdef __OPTIMIZE__
> > > > > 
> > > > > Using macros does not "optimise" anything,
> > 
> > Not quite true.  Using inline functions pessimizes everything that is
> > compiled without -O since the functions don't get inlined but code
> > for them is generated in each object file whether or not they are
> > used.  <sys/types.h> is included a lot, so having inline functions in
> > it is especially pessimal for the -O0 case.
> > 
> Hmm, even if these function declared static?  I was not able to
> reproduce this with static inline functions.

This seems to have been fixed.  Do you remember when compiling certain
libraries with -O0 -W<a lot> -Werror broke the world because stdio.h has
some static inline functions and there were warnings about these functions
being unused?  IIRC, code was generated for the functions, so the warning
was appropriate.  I can't reproduce this behaviour with the current gcc.

> > Writing the byte swapping using shifts and masks might be best in all
> > cases.  The compiler can in theory reduce shifts and masks to bswap on
> > i386's if that is best, but it can't look inside asm statements.
> > 
> And in practice (with -O), they are almost equivalent.  The following C
> code
> 
> #include <sys/types.h>
> 
> unsigned short
> foo(unsigned short a)
> {
>       return (htons(a));
> }
> 
> produces the following asm code diffs when using the current __asm version
> compared to the macro version:

> ...
> -#APP
> -     xchgb %ah, %al
> -#NO_APP
> +     rolw $8,%ax

Good, except there may be a problem with partial register stores (are
xchgb's handled better than rolw?).

I think we should use a non-asm version for the 16-bit swap.  gcc didn't
do so well for the 32-bit swap.

Bruce



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to