hello,
my friend tell me :
unsigned int v, mask
.../..
if(v & mask)
is really incredeable faster on core2 than
unsigned long long v, mask
..../..
if(v & mask)
because it exist micro-instruction and
with "immediate 32" but not with "immediate 64"
he have right?
thx.
|
|
0
|
|
|
|
Reply
|
pasdespam
|
7/24/2009 2:10:36 PM |
|
Bruno Causse wrote:
> hello,
>
> my friend tell me :
>
> unsigned int v, mask
> ../..
> if(v & mask)
>
> is really incredeable faster on core2 than
>
> unsigned long long v, mask
> .../..
> if(v & mask)
>
> because it exist micro-instruction and
> with "immediate 32" but not with "immediate 64"
>
> he have right?
Depends on the mask. There is no 64-bit immediate, but you can do a
64-bit 'and' with a sign-extended 32-bit immediate mask.
On x64, you have enough registers, so sacrificing a register for a mask
is much less of an issue than on IA-32.
|
|
0
|
|
|
|
Reply
|
tni
|
7/24/2009 4:19:54 PM
|
|
"Bruno Causse" <pasdespam@MUNGED.microcosmotalk.com> wrote in message
news:4a69c0dc$0$5650$9a6e19ea@unlimited.newshosting.com...
>
> my friend tell me :
>
> unsigned int v, mask
> ../..
> if(v & mask)
>
> is really incredeable faster on core2 than
>
> unsigned long long v, mask
> .../..
> if(v & mask)
>
Is the mask a variable - as you posted - or is it a constant? Masks in C
are usually constants. It makes a difference as to what instructions are
likely to be generated. If the mask is a variable as you posted, it's
likely that the binary-and instruction will be between registers or memory
and register. In which case, there is no code with an immediate. I.e.,
your question (below) about immediates doesn't make sense. If the mask was
supposed to be a constant, then you'll likely end up with instructions using
immediates. I.e., your question makes sense, but your examples aren't
correct C.
A 64-bit compiler's sizeof(long long) is commonly 8 (64-bits). But, the
sizeof(int) varies. Is your compiler's sizeof(int) equal to 4 (32-bits) or
8 (64-bits)? It's likely 4. Most 64-bit C compilers use 32-bit int's and
64-bit pointers and long long's. It's called an LLP64 or LP64 data model.
But, others use 64-bit for all three. Those are called ILP64 or SILP64 data
model.
So, depending on your compiler's data model, compiler's emitted code, and
your code, you could have a many different possible combinations for the two
examples... Many things are possible. It's possible the compiler is
generating an 32-bit immediate form for both - which would mean something
else is going on. It's possible the compiler is generating register-memory
instructions for the "unsigned long long" case which are slower than
immediates. This might be accessing non-local or uncached memory slowing
everything down if the cpu's cache is very fast compared to main memory.
It's also possible the compiler is generating multiple instructions for the
"unsigned long long" case to generate an _unsigned_ 64-bit binary-and.
Whereas, a binary-and with a _signed_ "long long" might be using a single
instruction.
One thing to check is that a 64-bit constant isn't within the range of a
64-bit value created by sign-extending a 32-bit value. I.e., in hex you
want to make sure the upper eight half of the 64-bit constant isn't 0's or
F's. The compiler could truncate it to 32-bits as an optimization.
> because it exist micro-instruction and
> with "immediate 32" but not with "immediate 64"
>
> he have right?
That's one possible explanation. But, as I see it, there could be a quite a
few others...
Rod Pemberton
|
|
0
|
|
|
|
Reply
|
Rod
|
7/25/2009 1:01:38 PM
|
|
Rod Pemberton <do_not_have@nohavenot.cmm> wrote:
> Is the mask a variable - as you posted - or is it a constant? Masks in C
> are usually constants. It makes a difference as to what instructions are
> likely to be generated. If the mask is a variable as you posted, it's
> likely that the binary-and instruction will be between registers or memory
> and register. In which case, there is no code with an immediate. I.e.,
> your question (below) about immediates doesn't make sense. If the mask was
> supposed to be a constant, then you'll likely end up with instructions using
> immediates. I.e., your question makes sense, but your examples aren't
> correct C.
>
yes, constant, sorry,
> A 64-bit compiler's sizeof(long long) is commonly 8 (64-bits). But, the
> sizeof(int) varies. Is your compiler's sizeof(int) equal to 4 (32-bits) or
> 8 (64-bits)? It's likely 4. Most 64-bit C compilers use 32-bit int's and
> 64-bit pointers and long long's. It's called an LLP64 or LP64 data model.
> But, others use 64-bit for all three. Those are called ILP64 or SILP64 data
> model.
>
> So, depending on your compiler's data model, compiler's emitted code, and
> your code, you could have a many different possible combinations for the two
> examples... Many things are possible. It's possible the compiler is
> generating an 32-bit immediate form for both - which would mean something
> else is going on. It's possible the compiler is generating register-memory
> instructions for the "unsigned long long" case which are slower than
> immediates. This might be accessing non-local or uncached memory slowing
> everything down if the cpu's cache is very fast compared to main memory.
> It's also possible the compiler is generating multiple instructions for the
> "unsigned long long" case to generate an _unsigned_ 64-bit binary-and.
> Whereas, a binary-and with a _signed_ "long long" might be using a single
> instruction.
>
> One thing to check is that a 64-bit constant isn't within the range of a
> 64-bit value created by sign-extending a 32-bit value. I.e., in hex you
> want to make sure the upper eight half of the 64-bit constant isn't 0's or
> F's. The compiler could truncate it to 32-bits as an optimization.
|
|
0
|
|
|
|
Reply
|
PasDeSpam
|
7/25/2009 6:42:41 PM
|
|
|
3 Replies
99 Views
(page loaded in 0.125 seconds)
Similiar Articles: Access 10 (64bit) -Integer & Table size - comp.databases.ms-access ...... LongLong and PtrSafe, a new function: CLngLng() >and new compilation constants: VBA7 ... which you can do with table ... Suitable Integer Square Root Algorithm for 32-64 ... Table for x86 arithmetic instructions - comp.lang.asm.x86 ...All this operations can use byte/w/dw/(qw) and immediates can be also signed bytes ... Memory operands and all possible addressing opportunities for 16/32/64 bit modes ... x86-64 and calling conventions - comp.compilers... system service, I translate my stack layout to the Windows/Mac/Linux/FreeBSD/32/64 ... gcc I've used "gcc -S" on will use the mov approach even if all arguments are constants. x86 instruction size length - comp.lang.asm.x86Some also have immediates: 80 C0 02 => add al, 0x02. The ModR/M byte only goes ... compatible long mode): the 67h override alters the address-size from 64-bit default to 32 ... icc inline assembly - comp.lang.asm.x86C inline assembler & accessing constants - comp.lang.asm.x86 ... My current job is ... Inline assembly is only supported by the IA-32 and Intel® 64 C++ compilers (icc and icpc ... Conditional compile in VHDL - comp.lang.vhdlI just want to have multiple sets of constants in my package, and ... medium => ( PixelsPerLine => 64, LinesPerFrame => 32 ... size of a derived type containing pointers... - comp.lang.fortran ...In C, character constants, such as 'x', have type int, and so sizeof('x')==sizeof ... function is undesirable for implementations that need to work in 32- and 64-bit ... How to compile COM components written in VC6.0 in Visual Studio ...FWIW: Look in the file sdkddkver.h for the meanings of _WIN32_WINNT constants and ... for real, code a function fptest.c and compile ... comp.lang.asm.x86... it's 64 ... improve strlen - comp.lang.asm.x86... mov [esp-16], ebp mov ebx, 80808080h ; load immediates ... you are willing to write this in assembler, why stick to 32-bit alu code? Why not write this doing 64 ... converting C/Visual BASIC code to MATLAB - comp.soft-sys.matlab ...How do I convert global constants into MATLAB? For example ... short /* CAMERA_TYPE */ cameraType; char name[64 ... 1/6/2011 3:53:32 AM Gentle Introduction to x86-64 Assembly - AMD64 SubpageImmediates. Immediate values inside instructions remain 32 bits and their value is sign extended to 64 bits before calculation. This means that: 32-bit to 64-bit Migration ConsiderationsIn C and C++, type identification of constants follows explicit rules. However, programs that use constants exceeding the limit (relying on a 2's complement ... 7/16/2012 9:28:16 PM
|