Author: martin fierz
Date: 14:20:20 12/03/04
Go up one level in this thread
On December 03, 2004 at 16:24:45, Dieter Buerssner wrote:
>On December 03, 2004 at 16:09:43, martin fierz wrote:
>
>>i have always found & to be a surprisingly large amount faster than %, even when
>>using #defined power-of-2-constants.
>
>Hmmm - can you show an example? (just a code snippet)
hmmm yourself :-) - i cannot reproduce it! i just tried with MSVC on my connect
4 program and don't see the effect any more. i guess i have to retract my
outrageous statement!
cheers
martin
>I assume, you used unsigned integers (for signed integers, the optimization may
>not be possible).
>
>Did you do % in 64-bit?
>
>Cheers,
>Dieter
>
>
>G:\src>type martin.c
>#define CONST (1024*1024)
>
>unsigned mod_method(unsigned long hk)
>{
> return hk%CONST;
>}
>
>unsigned and_method(unsigned long hk)
>{
> return hk&(CONST-1);
>}
>
>G:\src>cl -O2 -c -FA martin.c
>Optimierender Microsoft (R) 32-Bit C/C++-Compiler, Version 12.00.8168, fuer x86
>Copyright (C) Microsoft Corp 1984-1998. Alle Rechte vorbehalten.
>
>martin.c
>
>G:\src>type martin.asm
>[...]
>_hk$ = 8
>_mod_method PROC NEAR ; COMDAT
>; File martin.c
>; Line 5
> mov eax, DWORD PTR _hk$[esp-4]
> and eax, 1048575 ; 000fffffH
>; Line 6
> ret 0
>_mod_method ENDP
>_TEXT ENDS
>PUBLIC _and_method
>; COMDAT _and_method
>_TEXT SEGMENT
>_hk$ = 8
>_and_method PROC NEAR ; COMDAT
>; Line 10
> mov eax, DWORD PTR _hk$[esp-4]
> and eax, 1048575 ; 000fffffH
>; Line 11
> ret 0
>_and_method ENDP
>_TEXT ENDS
>END
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.