Binary package hint: gcc
Gcc version - 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
Kubuntu version dapper drake - 6.06
code was compiled with the following options....
-O3 -g3 -ggdb -Wall -mtune=pentium4 -mmmx -msse -msse2 -ffast-math -funsafe-math-optimizations -ffinite-math-only -fno-trapping-math -fsingle-precision-constant -fprefetch-loop-arrays -fomit-frame-pointer -mno-push-args -DNDEBUG -D_GNU_SOURCE -D_REENTRANT
The following C code snipit was compiled incorrectly...
#define LARGEST_BIT(x,retval) __asm("bsrl %0, %1;" : "=r"(retval) : "r"(x)) #define MAX_CAHCEBLOCK_SIZE 4095 <.....> const unsigned int numBits = sizeof( size_t ) * 8; unsigned int largestBit; unsigned int shiftOffset; size_t floorOfSize; size_t ceilOfSize; LARGEST_BIT( size, largestBit ); floorOfSize = 1 << largestBit; shiftOffset = ( ( floorOfSize - size ) >> ( numBits - 1 ) ); ceilOfSize = 1 << ( shiftOffset + largestBit) ; return ( size < MAX_CAHCEBLOCK_SIZE ) ? ceilOfSize : size; <.....> and the resultant asm code was...
bsr %ecx,%ebx mov $0x1, %edx mov %edx,%eax shl %cl,%eax sub %ebx,%eax shr $0x1f,%eax add %eax,%ecx shl %cl,%edx cmp $0xfff,%ebx cmvbe %edx,%ebx
If the C variable size equals 12 the C code will return 12, the asm code from gcc will return 4096.
Binary package hint: gcc
Gcc version - 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
Kubuntu version dapper drake - 6.06
code was compiled with the following options....
-O3 -g3 -ggdb -Wall -mtune=pentium4 -mmmx -msse -msse2 -ffast-math -funsafe- math-optimizati ons -ffinite-math-only -fno-trapping-math -fsingle- precision- constant -fprefetch- loop-arrays -fomit- frame-pointer -mno-push-args -DNDEBUG -D_GNU_SOURCE -D_REENTRANT
The following C code snipit was compiled incorrectly...
#define LARGEST_ BIT(x,retval) __asm("bsrl %0, %1;" : "=r"(retval) : "r"(x))
#define MAX_CAHCEBLOCK_SIZE 4095
<.....>
const unsigned int numBits = sizeof( size_t ) * 8;
unsigned int largestBit;
unsigned int shiftOffset;
size_t floorOfSize;
size_t ceilOfSize;
LARGEST_BIT( size, largestBit );
floorOfSize = 1 << largestBit;
shiftOffset = ( ( floorOfSize - size ) >> ( numBits - 1 ) );
ceilOfSize = 1 << ( shiftOffset + largestBit) ;
return ( size < MAX_CAHCEBLOCK_SIZE ) ? ceilOfSize : size;
<.....>
and the resultant asm code was...
bsr %ecx,%ebx
mov $0x1, %edx
mov %edx,%eax
shl %cl,%eax
sub %ebx,%eax
shr $0x1f,%eax
add %eax,%ecx
shl %cl,%edx
cmp $0xfff,%ebx
cmvbe %edx,%ebx
If the C variable size equals 12 the C code will return 12, the asm code from gcc will return 4096.