MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / LSB

Function LSB

source/util/bitutils.h:211–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209// Returns the the least significant bit from |value|.
210template <typename T>
211constexpr T LSB(T value) {
212 static_assert(std::is_integral<T>::value, "LSB requires integer type");
213 if constexpr (std::is_unsigned_v<T>) {
214 // Prevent warnings about doing a -x on unsigned values.
215 return value & (~value + 1);
216 } else {
217 return value & -value;
218 }
219}
220
221static_assert(LSB<uint32_t>(UINT32_MAX) == uint32_t(0x00000001), "LSB failed");
222static_assert(LSB<uint32_t>(0x10001000) == uint32_t(0x00001000), "LSB failed");

Callers 1

RedundantAndAddSubFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected