# Processor specific optimizations for SSE2 instructions
[BitMagic C++ Library]

Collaboration diagram for Processor specific optimizations for SSE2 instructions:

## Data Structures

class | bm::sse_empty_guard
| SSE2 reinitialization guard class. More...

## Functions

BMFORCEINLINE void | bm::sse2_xor_arr_2_mask (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end, bm::word_t mask)
| XOR array elements to specified mask dst = *src ^ mask.
BMFORCEINLINE void | bm::sse2_andnot_arr_2_mask (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end, bm::word_t mask)
| Inverts array elements and NOT them to specified mask dst = ~*src & mask.
BMFORCEINLINE void | bm::sse2_and_arr (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end)
| AND array elements against another array dst &= *src.
BMFORCEINLINE void | bm::sse2_or_arr (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end)
| OR array elements against another array dst |= *src.
BMFORCEINLINE void | bm::sse2_xor_arr (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end)
| OR array elements against another array dst ^= *src.
BMFORCEINLINE void | bm::sse2_sub_arr (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end)
| AND-NOT (SUB) array elements against another array dst &= ~*src.
BMFORCEINLINE void | bm::sse2_set_block (__m128i *BMRESTRICT dst, __m128i *BMRESTRICT dst_end, bm::word_t value)
| SSE2 block memset dst = value.
BMFORCEINLINE void | bm::sse2_copy_block (__m128i *BMRESTRICT dst, const __m128i *BMRESTRICT src, const __m128i *BMRESTRICT src_end)
| SSE2 block copy dst = *src.
BMFORCEINLINE void | bm::sse2_invert_arr (bm::word_t *first, bm::word_t *last)
| Invert array elements dst = ~*dst or dst ^= *dst.
bm::id_t | bm::sse2_bit_count (const __m128i *block, const __m128i *block_end)

## Function Documentation

BMFORCEINLINE void bm::sse2_and_arr | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end |
| ) |  |  |

AND array elements against another array dst &= *src.

Definition at line 126 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_andnot_arr_2_mask | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end,
|  | bm::word_t | mask |
| ) |  |  |

Inverts array elements and NOT them to specified mask dst = ~*src & mask.

Definition at line 98 of file bmsse_util.h.

bm::id_t bm::sse2_bit_count | ( | const __m128i * | block,
|  | const __m128i * | block_end |
| ) |  |  | `[inline]`

SSE2 optimized bitcounting function implements parallel bitcounting algorithm for SSE2 instruction set.

    unsigned CalcBitCount32(unsigned b)
    {
        b = (b & 0x55555555) + (b >> 1 & 0x55555555);
        b = (b & 0x33333333) + (b >> 2 & 0x33333333);
        b = (b + (b >> 4)) & 0x0F0F0F0F;
        b = b + (b >> 8);
        b = (b + (b >> 16)) & 0x0000003F;
        return b;
    }

Definition at line 64 of file bmsse2.h.

References BM_ALIGN16ATTR.

BMFORCEINLINE void bm::sse2_copy_block | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end |
| ) |  |  |

SSE2 block copy dst = *src.

Definition at line 322 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_invert_arr | ( | bm::word_t * | first,
|  | bm::word_t * | last |
| ) |  |  |

Invert array elements dst = ~*dst or dst ^= *dst.

Definition at line 366 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_or_arr | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end |
| ) |  |  |

OR array elements against another array dst |= *src.

Definition at line 167 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_set_block | ( | __m128i *BMRESTRICT | dst,
|  | __m128i *BMRESTRICT | dst_end,
|  | bm::word_t | value |
| ) |  |  |

SSE2 block memset dst = value.

Definition at line 288 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_sub_arr | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end |
| ) |  |  |

AND-NOT (SUB) array elements against another array dst &= ~*src.

Definition at line 248 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_xor_arr | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end |
| ) |  |  |

OR array elements against another array dst ^= *src.

Definition at line 207 of file bmsse_util.h.

BMFORCEINLINE void bm::sse2_xor_arr_2_mask | ( | __m128i *BMRESTRICT | dst,
|  | const __m128i *BMRESTRICT | src,
|  | const __m128i *BMRESTRICT | src_end,
|  | bm::word_t | mask |
| ) |  |  |

XOR array elements to specified mask dst = *src ^ mask.

Definition at line 72 of file bmsse_util.h.