What are the advantages of a 64-bit processor?

There’s a great article on Wikipedia about the differences and benefits of 64bit Intel/AMD cpus over their 32 bit versions. It should have all the information you need. Some on the key differences are: 16 general purpose registers instead of 8 Additional SSE registers A no execute (NX) bit to prevent buffer overrun attacks

How has CPU architecture evolution affected virtual function call performance?

AMD processor in the early-gigahertz era had a 40 cycle penalty every time you called a function Huh.. so large.. There is an “Indirect branch prediction” method, which helps to predict virtual function jump, IF there was the same indirect jump some time ago. There is still a penalty for first and mispredicted virt. function … Read more

What is faster (x < 0) or (x == -1)?

That depends entirely on the ISA you’re compiling for, and the quality of your compiler’s optimizer. Don’t optimize prematurely: profile first to find your bottlenecks. That said, in x86, you’ll find that both are equally fast in most cases. In both cases, you’ll have a comparison (cmp) and a conditional jump (jCC) instructions. However, for … Read more

What does ‘bank’ing a register mean?

Register banking refers to providing multiple copies of a register at the same address. Taken from section 1.4.6 of the arm docs The term is referring to a solution for the problem that not all registers can be seen at once. There is a different register bank for each processor mode. The banked registers give … Read more

CPU SIMD vs GPU SIMD?

Both CPUs & GPUs provide SIMD with the most standard conceptual unit being 16 bytes/128 bits; for example a Vector of 4 floats (x,y,z,w). Simplifying: CPUs then parallelize more through pipelining future instructions so they proceed faster through a program. Then next step is multiple cores which run independent programs. GPUs on the other hand … Read more

How does cpu communicate with peripherals?

In older architectures, peripherals were accessed via a separate mechanism to memory access with special I/O instructions. On x86, there were (and still are!) “in” and “out” instructions for transferring bytes between the CPU and a peripheral. Peripherals were given addresses, for example 0x80 for the keyboard. Simplifying a lot, doing “in 0x80” would read … Read more

Is bit shifting O(1) or O(n)?

Some instruction sets are limited to one bit shift per instruction. And some instruction sets allow you to specify any number of bits to shift in one instruction, which usually takes one clock cycle on modern processors (modern being an intentionally vague word). See dan04’s answer about a barrel shifter, a circuit that shifts more … Read more