Author: Daniel Mehrmannn
Date: 12:12:27 03/19/05
Go up one level in this thread
On March 19, 2005 at 09:51:46, Gerd Isenberg wrote: >On March 19, 2005 at 04:41:26, Thomas Gaksch wrote: > >>On March 19, 2005 at 04:22:58, Thomas Gaksch wrote: >> >>>sorry, i never used the makefile or an other compiler than vc. i always build >>>the code with microsoft visual c++ 6.0. with visual c++ 6.0 it works with only >>>including #include <math.h> >>>but math.h is only needed for the abs function. you also could write a macro for >>>the abs function. >>>thomas >> >>sorry, i forgot the example for an abs macro: >>#define ABS(x) ((x)<0?-(x):(x)) >> >>bye >>thomas > >Hi Thomas, > >with good predictable data pattern the macro, producing a conditional jump is >fine. Trying to outperform the compiler with arithmetic shift right to force >branchless code is often worse, ... > >long abs(long x) { > long y; > y = x >> 31; > return (x ^ y) - y; >} > >... until compiler is smart enough to produce this x86 code which seems shortest >and fastest abs() at least for random data. And iirr this is the code of msc6 >abs-intrinsic: > > 99 cdq > 33 C2 xor eax,edx > 2B C2 sub eax,edx > >See http://chessprogramming.org/cccsearch/ccc.php?art_id=304882 >or use CCC-Search-Engine with Subject "Implementation of the abs() function" to >find further details. > >Cheers, >Gerd Hi Gerd :) I tryed the same and my implemtation was allso slower as the MS Vc 6.0 include :( Daniel
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.