From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5ff6e0c3de8331c0 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 03 Jul 2007 22:22:06 -0500 From: "Steve" Newsgroups: comp.lang.ada References: <1183404856.375083.160890@q69g2000hsb.googlegroups.com> <1183485842.725620.199490@w5g2000hsg.googlegroups.com> <1183491750.177186.154490@k29g2000hsd.googlegroups.com> Subject: Re: sub-optimal code for packed boolean arrays -- bug or inherent limitation Date: Tue, 3 Jul 2007 20:22:36 -0700 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Original Message-ID: X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 24.20.111.245 X-Trace: sv3-Ly17hMKe0eoIu0vzER3x5WDyNsWftpGaNVFYUlBS9L4Dn20+r0MAh1RphcvVA7oStECG/afse00yZb5!389BRwuz7VD5G5ngpaKu5zVf6wS8hnsz0/S7HwY2ctK67UhzRYDMnEHEZFGusZjM2IwEZWqpuhdI!q7wfYPRhg7rcdtsGjuZ8VvqzuuMVcA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.35 Xref: g2news1.google.com comp.lang.ada:16403 Date: 2007-07-03T20:22:36-07:00 List-Id: "Alinabi" 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)