comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: sub-optimal code for packed boolean arrays -- bug or inherent limitation
Date: Tue, 3 Jul 2007 20:22:36 -0700
Date: 2007-07-03T20:22:36-07:00	[thread overview]
Message-ID: <T--dnWoX157DjxbbnZ2dnUVZ_hWdnZ2d@comcast.com> (raw)
In-Reply-To: 1183491750.177186.154490@k29g2000hsd.googlegroups.com

"Alinabi" <alexander.the.average@gmail.com> wrote in message 
news:1183491750.177186.154490@k29g2000hsd.googlegroups.com...
[snip]
>
> As for the proof that the hand coded version is faster, here it is:
>
> Hand coded: 2 MOV, 1 SHL, 1 XOR
> Compiler:   2 MOV, 1 SHL, 1 XOR, 1 SHR, 1 ROL, 2 AND, 1 OR
> ---------------------
> 5 extraneous instructions, Q.E.D.
>

Twenty years ago I might ave agreed with this logic, but not today.

In the good ole' days you could associate an amount of time with each 
instructions, add them up and get a total amount of execution time.  This 
hasn't been possible for a long time.  Ever heard of "instruction 
scheduling" and "concurrent execution"?

Todays CPU's contain "pipelines" that sometimes merge several operations 
into a single clock.  In some cases you will find that NOP's are added to 
increase the speed of execution based on a detailed knowledge of the 
underlying processor.

I agree with Jeff's assesment.  You must benchmark to measure and compare 
performance.

I work frequently with time intensive code where simulating more 
permutations translate to more value recovered.  These small differences in 
code generation seldom have a significant impact on the overall performance. 
Greater benefits are found by changes to algorithms or approaches to a 
problem.

Regards,
Steve
(The Duck)





  parent reply	other threads:[~2007-07-04  3:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02 19:34 sub-optimal code for packed boolean arrays -- bug or inherent limitation Alinabi
2007-07-02 20:08 ` Ludovic Brenta
2007-07-03  1:01 ` Jeffrey R. Carter
2007-07-03  7:22   ` Harald Korneliussen
2007-07-03  8:37     ` Georg Bauhaus
2007-07-03  7:59 ` gautier_niouzes
2007-07-03  9:25 ` Stefan Lucks
2007-07-03 12:40   ` Stefan Lucks
2007-07-03 15:42 ` Adam Beneschan
2007-07-03 18:04 ` Alinabi
2007-07-03 18:09   ` Alinabi
2007-07-03 18:17     ` Alinabi
2007-07-10  2:06       ` Randy Brukardt
2007-07-03 18:36   ` Jeffrey R. Carter
2007-07-03 19:42     ` Alinabi
2007-07-04  1:12       ` Jeffrey R. Carter
2007-07-04 10:15         ` Jeffrey Creem
2007-07-04 18:28           ` Jeffrey R. Carter
2007-07-04  3:22       ` Steve [this message]
2007-07-04  6:31         ` Harald Korneliussen
2007-07-08 22:53     ` Robert A Duff
2007-07-09  6:09       ` tmoran
2007-07-04  9:00   ` Jean-Pierre Rosen
2007-07-04 18:27     ` tmoran
2007-07-04 19:16       ` Pascal Obry
2007-07-05  1:45         ` tmoran
2007-07-05  4:53       ` Jeffrey R. Carter
2007-07-04 18:51     ` tmoran
2007-07-08 22:58 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox