7 Sep
2006
7 Sep
'06
15:10
On Thursday 07 September 2006 2:56 am, Jan Engelhardt wrote:
Every use of uint64_t in code will be emulated by gcc for 32-bit archs. Which seems, from the asm dump, costly. While this is true, let me restate it. In a 32-bit application (under a 32-bit OS or a 64-bit OS), the application only has 8 32-bit registers, so the C language types: long long, int64_t, uint64_t will require multiple register loads as well as a couple of operations. So, in pseudo assembler code: int64_t x, y, rc; load x (low order 32 bits) into reg a1 load y (low order 32-bits) into reg a2. Add a1 and a2 storing result in reg a1 Store result into rc (low order 32-bits) load x (high order 32 bits) into reg a1 load y (high order 32-bits) into reg a2. Add with carry a1 and a2 storing result in a1. Store a1 into rc (high order 32-bits). In this case, you've got to do 4 loads, 2 adds and 2 stores. In a 64-bit system there are 2 loads, 1 operation, 1 store.
Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9