Addressing the adding situation
9 days ago
- #x86-architecture
- #compiler-optimizations
- #assembly-programming
- x86 architecture typically allows only two operands per instruction, unlike ARM which supports three operands for operations like addition.
- The `lea` (Load Effective Address) instruction in x86 is creatively used by compilers to perform three-operand addition by leveraging the memory addressing system without actual memory access.
- Using `lea` for addition can save instructions, preserve original operand values, and efficiently utilize execution units, making it a preferred method for compilers.
- The post is part of the 'Advent of Compiler Optimisations 2025' series, exploring compiler optimizations, with this entry focusing on addition operations in x86.