Which opcodes are faster at the CPU level?
Posted
by
Geotarget
on Game Development
See other posts from Game Development
or by Geotarget
Published on 2012-04-11T09:52:59Z
Indexed on
2012/04/11
11:43 UTC
Read the original article
Hit count: 292
In every programming language there are sets of opcodes that are recommended over others. I've tried to list them here, in order of speed.
- Bitwise
- Integer Addition / Subtraction
- Integer Multiplication / Division
- Comparison
- Control flow
- Float Addition / Subtraction
- Float Multiplication / Division
Where you need high-performance code, C++ can be hand optimized in assembly, to use SIMD instructions or more efficient control flow, data types, etc. So I'm trying to understand if the data type (int32 / float32 / float64) or the operation used (*
, +
, &
) affects performance at the CPU level.
- Is a single multiply slower on the CPU than an addition?
- In MCU theory you learn that speed of opcodes is determined by the number of CPU cycles it takes to execute. So does it mean that multiply takes 4 cycles and add takes 2?
- Exactly what are the speed characteristics of the basic math and control flow opcodes?
- If two opcodes take the same number of cycles to execute, then both can be used interchangeably without any performance gain / loss?
- Any other technical details you can share regarding x86 CPU performance is appreciated
© Game Development or respective owner