Creează un cont pentru a te abona la acest blog și a-i urmări articolele pe pagina Lectură.
-
Suppose we need to get a mask when a nonnegative argument is greater then some constant value; in other words, we want to evaluate following expression: if x > const_n then mask := 0xffffffff; else mask := 0x00000000; Portable branchless solution:…
-
Tests Two scenarios of test were considered: The table size is hardware friendly, i.e. is multiply of implementation base step; also address of table is aligned: all procedures use MOVUPS, all procedures use MOVAPS.
-
Method from Bit Twiddling Hacks: (x !
-
Suppose we have to exchange (or just move) two registers A and B: C := A xor B C := 0 if condition is not true A := A xor C B := B xor C If C is 0, then A and B left unchanged, else A and B are swapped.
-
The idea is quite simple: we do not have a single stl::map<string, something>, but a vector of maps, indexed with O(1) time — each map stores keys sharing certain properties.
-
Problem: calculate value of sign(x): -1 when x < 0 0 when x = 0, +1 when x > 0.
-
The most general algorithm mask bit: [10111010] => [00010000] clone word: a=[00010000], b=[00010000] shift bit in first word to MSB, and to LSB in second word: a=[10000000], b=[00000001] subtract c = a - b: c=[01111111] add missing MSB c = c OR a: c=[…
-
Method presented here allows to get any bit permutation, transposition is just one of possible operations.
-
Suppose that a database stores some kind of a dictionary and an user picks some items, but wants to keep the order.
-
man locatedb says: "Databases can not be concatenated together, even if the first (dummy) entry is trimmed from all but the first database.
-
Unusual application of PHMINPOSUW instruction as key part of insertion sort for 8 element tables.
-
Introduction Image crossfading is a kind of alpha blending where a final pixel is the result of linear interpolation of pixels from two images: result_pixel = pixel1 * alpha + pixel2 * (1 - alpha) where alpha lie in range [0, 1].
-
There is no such instruction — CVTDQ2PS converts signed 32-bit ints.
-
Converting float to int Few years ago I've developed a method that do not need any floating-point operations — description is written in Polish, but sample code should be easy to understand.
-
Branch-less x86 code: movl %eax, %ebx sarl $32, %ebx ; fill ebx with sign bit xorl %ebx, %eax ; negate eax (if negative) subl %ebx, %eax ; increment eax by 1 (if negative) SSE2: pshufd $0b11110101, %xmm0, %xmm1 ; populate…
-
RDTSC is incremented with bus-clock cycles, and then multiplied by core-clock/bus-clock ratio.
-
Read-write variables asm( "
-
Introduction Alpha blending refers to many different operations.
-
Proof In the proof we consider three cases: x < y, x = y and x > y.
-
x86 code The x86 code is a base for further improvements.
-
Introduction Basically this kind of conversion needs following steps: extract components R, G and B (using bitwise and) extend words from 6 or 5 bits to 8 bits (shift left) place components at desired places in a 32-bit word (shift, bitwise or) R = (pixel…
-
Introduction String search is a common task in text processing.
-
Introduction Population count is a procedure of counting number of ones in a bit string.
-
SIMD algorithm Instruction PSHUFB does parallel lookup from 16-byte array stored in an XMM register — this is exactly what bin to hex conversion needs.