Author: Gerd Isenberg
Date: 01:14:35 01/17/04
Go up one level in this thread
On January 16, 2004 at 22:15:34, Federico Corigliano wrote: >Hi > >In my engine I have a lot of #defines as: >#define FileA 0xFFFFFFFF <- I don't remember the real value >and I want to convert it to: >const UINT64 FileA = 0xFFFFFFFFF; >I the change can affect the speed. As I often use MSVC Debugger, it's boring to >translate every #define to the respective number. > >Federico For assembler instructions that means immediate operand versus memory operand. With short 8/16 or even 32 bit constants in general, immediate operands inside the opcode are faster, rather than an additional memory read. With 64-bit constants it is questionable and you may try both, as Bob suggested. The opcode of mov/and... gets really huge, because all eight (or 2*4) immediate bytes are coded inside it, an address requires only 4byte inside the opcode of x86-32. On the other hand with x86-64 in 64-bit mode addresses are eight bytes, so the size aspects disappears with AMD64. Anyway i would leave the #define and use it inside your const declaration. And it makes sense to put often used oonstants in one context inside a structure or inside an array. Then the memeory may addressed indirectly via some base register/index resgister and small constant offsets which may be coded in one or four bytes. // with mapping a1=0 h1=7, a2=8, h8=63 #define FILEABB 0x0101010101010101ULL const BitBoard fileAbb = FILEABB; const BitBoard fileBitboards[8] = { FILEABB, FILEBBB, FILECBB, FILEDBB, FILEEBB, FILEFBB, FILEGBB, FILEHBB, }; If you use fileAbb or fileBitboards[0] doesn't matter, same code except the address. SIMD-instruction sets like MMX- or SSE2 don't offer any immediate operands at all. But specially FILE-constants or their complements may be processed easily: using pxor to set zero, pcmpeq to set -1 and to do bytewise psub of 0 - (-1), ready is the FILEA-mask, other files require further subs or shift. Gerd
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.