cmp_lt.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /* Copyright (C) 2013-2014 Povilas Kanapickas <[email protected]>
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef LIBSIMDPP_SIMDPP_CORE_CMP_LT_H
  7. #define LIBSIMDPP_SIMDPP_CORE_CMP_LT_H
  8. #ifndef LIBSIMDPP_SIMD_H
  9. #error "This file must be included through simd.h"
  10. #endif
  11. #include <simdpp/types.h>
  12. #include <simdpp/detail/insn/cmp_lt.h>
  13. #include <simdpp/core/detail/scalar_arg_impl.h>
  14. namespace simdpp {
  15. namespace SIMDPP_ARCH_NAMESPACE {
  16. /** Compares the values of two signed int8x16 vectors for less-than
  17. @code
  18. r0 = (a0 < b0) ? 0xff : 0x0
  19. ...
  20. rN = (aN < bN) ? 0xff : 0x0
  21. @endcode
  22. @par 256-bit version:
  23. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  24. */
  25. template<unsigned N, class E1, class E2> SIMDPP_INL
  26. mask_int8<N,expr_empty> cmp_lt(const int8<N,E1>& a,
  27. const int8<N,E2>& b)
  28. {
  29. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  30. }
  31. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int8, int8)
  32. /** Compares the values of two unsigned int8x16 vectors for less-than
  33. @code
  34. r0 = (a0 < b0) ? 0xff : 0x0
  35. ...
  36. rN = (aN < bN) ? 0xff : 0x0
  37. @endcode
  38. @par 128-bit version:
  39. @icost{SSE2-AVX2, 3-4}
  40. @icost{XOP, 1}
  41. @par 256-bit version:
  42. @icost{SSE2-AVX, 6-7}
  43. @icost{AVX2, 3-4}
  44. @icost{XOP, NEON, ALTIVEC, 2}
  45. */
  46. template<unsigned N, class E1, class E2> SIMDPP_INL
  47. mask_int8<N,expr_empty> cmp_lt(const uint8<N,E1>& a,
  48. const uint8<N,E2>& b)
  49. {
  50. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  51. }
  52. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int8, uint8)
  53. /** Compares the values of two signed int16x8 vectors for less-than
  54. @code
  55. r0 = (a0 < b0) ? 0xffff : 0x0
  56. ...
  57. rN = (aN < bN) ? 0xffff : 0x0
  58. @endcode
  59. @par 256-bit version:
  60. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  61. */
  62. template<unsigned N, class E1, class E2> SIMDPP_INL
  63. mask_int16<N,expr_empty> cmp_lt(const int16<N,E1>& a,
  64. const int16<N,E2>& b)
  65. {
  66. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  67. }
  68. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int16, int16)
  69. /** Compares the values of two unsigned int16x8 vectors for less-than
  70. @code
  71. r0 = (a0 < b0) ? 0xffff : 0x0
  72. ...
  73. rN = (aN < bN) ? 0xffff : 0x0
  74. @endcode
  75. @par 128-bit version:
  76. @icost{SSE2-AVX2, 3-4}
  77. @icost{XOP, 1}
  78. @par 256-bit version:
  79. @icost{SSE2-AVX, 6-7}
  80. @icost{AVX2, 3-4}
  81. @icost{XOP, NEON, ALTIVEC, 2}
  82. */
  83. template<unsigned N, class E1, class E2> SIMDPP_INL
  84. mask_int16<N,expr_empty> cmp_lt(const uint16<N,E1>& a,
  85. const uint16<N,E2>& b)
  86. {
  87. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  88. }
  89. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int16, uint16)
  90. /** Compares the values of two signed int32x4 vectors for less-than
  91. @code
  92. r0 = (a0 < b0) ? 0xffffffff : 0x0
  93. ...
  94. rN = (aN < bN) ? 0xffffffff : 0x0
  95. @endcode
  96. @par 256-bit version:
  97. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  98. */
  99. template<unsigned N, class E1, class E2> SIMDPP_INL
  100. mask_int32<N,expr_empty> cmp_lt(const int32<N,E1>& a,
  101. const int32<N,E2>& b)
  102. {
  103. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  104. }
  105. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int32, int32)
  106. /** Compares the values of two unsigned int32x4 vectors for less-than
  107. @code
  108. r0 = (a0 < b0) ? 0xffffffff : 0x0
  109. ...
  110. rN = (aN < bN) ? 0xffffffff : 0x0
  111. @endcode
  112. @par 128-bit version:
  113. @icost{SSE2-AVX2, 3-4}
  114. @icost{XOP, 1}
  115. @par 256-bit version:
  116. @icost{SSE2-AVX, 6-7}
  117. @icost{AVX2, 3-4}
  118. @icost{XOP, NEON, ALTIVEC, 2}
  119. */
  120. template<unsigned N, class E1, class E2> SIMDPP_INL
  121. mask_int32<N,expr_empty> cmp_lt(const uint32<N,E1>& a,
  122. const uint32<N,E2>& b)
  123. {
  124. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  125. }
  126. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int32, uint32)
  127. /** Compares the values of two signed int64 vectors for less-than
  128. @code
  129. r0 = (a0 > b0) ? 0xffffffffffff : 0x0
  130. ...
  131. rN = (aN > bN) ? 0xffffffffffff : 0x0
  132. @endcode
  133. Supported since AVX2, NEON64. Not supported on ALTIVEC.
  134. */
  135. template<unsigned N, class E1, class E2> SIMDPP_INL
  136. mask_int64<N,expr_empty> cmp_lt(const int64<N,E1>& a,
  137. const int64<N,E2>& b)
  138. {
  139. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  140. }
  141. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int64, int64)
  142. /** Compares the values of two unsigned int64 vectors for less-than
  143. @code
  144. r0 = (a0 > b0) ? 0xffffffffffff : 0x0
  145. ...
  146. rN = (aN > bN) ? 0xffffffffffff : 0x0
  147. @endcode
  148. Supported since AVX2, NEON64. Not supported on ALTIVEC.
  149. */
  150. template<unsigned N, class E1, class E2> SIMDPP_INL
  151. mask_int64<N,expr_empty> cmp_lt(const uint64<N,E1>& a,
  152. const uint64<N,E2>& b)
  153. {
  154. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  155. }
  156. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_int64, uint64)
  157. /** Compares the values of two float32x4 vectors for less-than
  158. @code
  159. r0 = (a0 < b0) ? 0xffffffff : 0x0
  160. ...
  161. rN = (aN < bN) ? 0xffffffff : 0x0
  162. @endcode
  163. @par 256-bit version:
  164. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  165. */
  166. template<unsigned N, class E1, class E2> SIMDPP_INL
  167. mask_float32<N,expr_empty> cmp_lt(const float32<N,E1>& a,
  168. const float32<N,E2>& b)
  169. {
  170. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  171. }
  172. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_float32, float32)
  173. /** Compares the values of two float64x2 vectors for less-than
  174. @code
  175. r0 = (a0 < b0) ? 0xffffffffffffffff : 0x0
  176. ...
  177. rN = (aN < bN) ? 0xffffffffffffffff : 0x0
  178. @endcode
  179. @par 128-bit version:
  180. @novec{NEON, ALTIVEC}
  181. @par 256-bit version:
  182. @novec{NEON, ALTIVEC}
  183. @icost{SSE2-SSE4.1, 2}
  184. */
  185. template<unsigned N, class E1, class E2> SIMDPP_INL
  186. mask_float64<N,expr_empty> cmp_lt(const float64<N,E1>& a,
  187. const float64<N,E2>& b)
  188. {
  189. return detail::insn::i_cmp_lt(a.eval(), b.eval());
  190. }
  191. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_lt, mask_float64, float64)
  192. } // namespace SIMDPP_ARCH_NAMESPACE
  193. } // namespace simdpp
  194. #endif