Skip to content

Add signbit function

Reference issue

What does this implement/fix?

Checking the sign of a floating point value appears trivial, except when checking for -0. This is necessary for some frequently used math functions, such as pow. A consistent and efficient signbit will simplify implementation and improve performance of many floating point functions. This may also be a faster method of checking for negative values, as it uses shift operations instead of floating point comparisons.

AVX arithmetic shift: _mm256_srai_epi32, latency 1, CPI: 0.5

AVX floating point compare: _mm256_cmp_ps, latency 4, CPI: 0.5

std::signbit checks if the leading bit is set and returns a bool. These functions return a bitmask (all 1's for true, all 0's for false) of the same type so that it may be used for logical operations (but will evaluate to the same boolean value).

Also added an AVX2 packet op to perform arithmetic shift of int64_t packets -- Packet4l.

Additional information

Edited by Charles Schlosser

Merge request reports

Loading