comparison operations cannot be vectorized
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
Research direction
Start by locating the existing uint128 and int128 comparison operators and their tests; the issue does not name file paths or test targets. Check how those operators currently compare the high and low words, then evaluate the proposed individual comparison functions against the project’s conventions. Done when the six comparison operations work correctly for both integer types and the relevant tests pass.
Written by the indexing model from the issue text.
Description
I think it's more efficient to implement the six comparison functions individually and then use them in the operators.
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_uint128_eq(const uint128& x, const uint128& y) noexcept
{
#if BOOST_INT128_ENDIAN_LITTLE_BYTE
return (x.low == y.low) & (x.high == y.high);
#else
return (x.high == y.high) & (x.low == y.low);
#endif
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_uint128_ne(const uint128& x, const uint128& y) noexcept
{
#if BOOST_INT128_ENDIAN_LITTLE_BYTE
return (x.low != y.low) | (x.high != y.high);
#else
return (x.high != y.high) | (x.low != y.low);
#endif
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_uint128_lt(const uint128& x, const uint128& y) noexcept
{
return (x.high < y.high) | ((x.high == y.high) & (x.low < y.low));
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_uint128_gt(const uint128& x, const uint128& y) noexcept
{
return (x.high > y.high) | ((x.high == y.high) & (x.low > y.low));
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_uint128_le(const uint128& x, const uint128& y) noexcept
{
return !compare_uint128_lt(y, x);
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_uint128_ge(const uint128& x, const uint128& y) noexcept
{
return !compare_uint128_gt(y, x);
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_int128_eq(const int128& x, const int128& y) noexcept
{
#if BOOST_INT128_ENDIAN_LITTLE_BYTE
return (x.low == y.low) & (x.high == y.high);
#else
return (x.high == y.high) & (x.low == y.low);
#endif
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_int128_ne(const int128& x, const int128& y) noexcept
{
#if BOOST_INT128_ENDIAN_LITTLE_BYTE
return (x.low != y.low) | (x.high != y.high);
#else
return (x.high != y.high) | (x.low != y.low);
#endif
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_int128_lt(const int128& x, const int128& y) noexcept
{
return ((x.signed_high() < y.signed_high())) | ((x.high == y.high) & (x.low < y.low));
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_int128_gt(const int128& x, const int128& y) noexcept
{
return (x.signed_high() > y.signed_high()) | ((x.high == y.high) & (x.low > y.low));
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_int128_le(const int128& x, const int128& y) noexcept
{
return !compare_int128_lt(y, x);
}
BOOST_INT128_HOST_DEVICE BOOST_INT128_FORCE_INLINE constexpr bool compare_int128_ge(const int128& x, const int128& y) noexcept
{
return !compare_int128_gt(y, x);
}
- Dominant language
- C++
- Stars
- 22
- Forks
- 6
- Avg merge
- 17h 33m
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/int128
Similar issues
-
agent:WSL code-review linux pri:medium refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
kind/enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
psi29a/d2decomped#691 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
CachyOS/packageinstaller#144 ·
Maintainers usually reply within 1 day
-
(S1 - Need confirmation)
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CleverRaven/Cataclysm-DDA#89715 ·
Maintainers usually reply within 1 day