[OT] Bit twiddling homework

Marko Rauhamaa marko at pacujo.net
Fri Jul 20 12:39:21 EDT 2018


Chris Angelico <rosuav at gmail.com>:

> On Sat, Jul 21, 2018 at 1:14 AM, Grant Edwards
> <grant.b.edwards at gmail.com> wrote:
>> I refuse to believe there's an extant processor in common use where
>> an ADD is faster than an OR unless somebody shows me the processor
>> spec sheet.
>
> "Faster than"? I'd agree with you. But "as fast as"? I believe that's
> how most modern CPUs already operate. (Well, mostly.) There are
> sophisticated methods of daisy-chaining the carry bit that mean the
> overall addition can be performed remarkably quickly, and the end
> result is a one-clock ADD operation, same as OR. For most data, most
> code, and most situations, integer addition is exactly as fast as
> integer bit shift.

I'm guessing the clock speed is adjusted for the longest propagation
delays. According to

   <URL: https://en.wikipedia.org/wiki/Carry-lookahead_adder#Implementa
   tion_details>

the maximal gate delay of a 16-bit carry-lookahead-adder is 8 gate
delays. A 64-bit addition results in some more delay:

   <URL: https://en.wikipedia.org/wiki/Lookahead_carry_unit#64-bit_adder>


Marko



More information about the Python-list mailing list