From: Adrian Bunk <bunk@stusta.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] Correct imprecise >= comparisons
Date: Fri, 10 Feb 2006 00:30:26 +0000 [thread overview]
Message-ID: <20060210003026.GF3524@stusta.de> (raw)
In-Reply-To: <20060208185312.GA26914@rhlx01.fht-esslingen.de>
[-- Attachment #1: Type: text/plain, Size: 1526 bytes --]
On Fri, Feb 10, 2006 at 09:16:36AM +1100, Darren Jenkins wrote:
> On 2/9/06, Eric Sesterhenn <snakebyte@gmx.de> wrote:
>
> > snakebyte@alice:~$ gcc test.c
> > snakebyte@alice:~$ ./a.out
> > i>=3 : 11
> > i>3 : 28
> >
> > seems the >= actually performs faster on my athlon xp...
> >
> > on a non xp athlon i get this:
> > i>=3 : 11
> > i>3 : 31
> >
> > good i also checked an intel box :) my centrino gives the following:
> >
> > i>=3 : 66
> > i>3 : 47
> >
> > and a friends amd64
> >
> > i >= 3 : 8
> > i>3 : 22
> >
> > here the i>3 is faster... seems we need a macro for this stuff, which we
> > can change for each processor type ;-)
> >
> > Greetings, Eric
>
> Interesting
> I guess on alot of arch's doing
>
> if (value >= max+1)
> value = max;
>
> might be the more efficient.
>
> hmm will have to investigate further.
What is the purpose of all this?
With modern compilers, the general rule is to write readable C code and
let the compiler do the rest.
Exceptions could be in real hot paths, but even in such cases there's
the problem that tricky code performing better with today's compilers
might perform worse with future compilers (similar to the goto tricks
people used in the past to circumvent some compiler limitations).
> Darren J.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2006-02-10 0:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-08 18:53 [KJ] Correct imprecise >= comparisons Andreas Mohr
2006-02-09 0:06 ` Eric Sesterhenn
2006-02-09 12:20 ` Andreas Mohr
2006-02-09 12:44 ` Matthew Wilcox
2006-02-09 12:52 ` Eric Sesterhenn
2006-02-09 13:45 ` Andreas Mohr
2006-02-09 14:06 ` Eric Sesterhenn
2006-02-09 15:35 ` Håkon Løvdal
2006-02-09 22:16 ` Darren Jenkins
2006-02-10 0:30 ` Adrian Bunk [this message]
2006-02-10 1:05 ` Darren Jenkins
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=20060210003026.GF3524@stusta.de \
--to=bunk@stusta.de \
--cc=kernel-janitors@vger.kernel.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 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.