cmp_gt.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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_GT_H
  7. #define LIBSIMDPP_SIMDPP_CORE_CMP_GT_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_gt.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 int16x8 vectors for greater-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_gt(const int8<N,E1>& a,
  27. const int8<N,E2>& b)
  28. {
  29. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  30. }
  31. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int8, int8)
  32. /** Compares the values of two unsigned int16x8 vectors for greater-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, 2}
  45. @icost{NEON, ALTIVEC, 2}
  46. */
  47. template<unsigned N, class E1, class E2> SIMDPP_INL
  48. mask_int8<N,expr_empty> cmp_gt(const uint8<N,E1>& a,
  49. const uint8<N,E2>& b)
  50. {
  51. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  52. }
  53. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int8, uint8)
  54. /** Compares the values of two signed int16x8 vectors for greater-than
  55. @code
  56. r0 = (a0 > b0) ? 0xffff : 0x0
  57. ...
  58. rN = (aN > bN) ? 0xffff : 0x0
  59. @endcode
  60. @par 256-bit version:
  61. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  62. */
  63. template<unsigned N, class E1, class E2> SIMDPP_INL
  64. mask_int16<N,expr_empty> cmp_gt(const int16<N,E1>& a,
  65. const int16<N,E2>& b)
  66. {
  67. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  68. }
  69. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int16, int16)
  70. /** Compares the values of two unsigned int16x8 vectors for greater-than
  71. @code
  72. r0 = (a0 > b0) ? 0xffff : 0x0
  73. ...
  74. rN = (aN > bN) ? 0xffff : 0x0
  75. @endcode
  76. @par 128-bit version:
  77. @icost{SSE2-AVX2, 3-4}
  78. @icost{XOP, 1}
  79. @par 256-bit version:
  80. @icost{SSE2-AVX, 6-7}
  81. @icost{AVX2, 3-4}
  82. @icost{XOP, NEON, ALTIVEC, 2}
  83. */
  84. template<unsigned N, class E1, class E2> SIMDPP_INL
  85. mask_int16<N,expr_empty> cmp_gt(const uint16<N,E1>& a,
  86. const uint16<N,E2>& b)
  87. {
  88. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  89. }
  90. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int16, uint16)
  91. /** Compares the values of two signed int32x4 vectors for greater-than
  92. @code
  93. r0 = (a0 > b0) ? 0xffffffff : 0x0
  94. ...
  95. rN = (aN > bN) ? 0xffffffff : 0x0
  96. @endcode
  97. @par 256-bit version:
  98. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  99. */
  100. template<unsigned N, class E1, class E2> SIMDPP_INL
  101. mask_int32<N,expr_empty> cmp_gt(const int32<N,E1>& a,
  102. const int32<N,E2>& b)
  103. {
  104. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  105. }
  106. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int32, int32)
  107. /** Compares the values of two unsigned int32x4 vectors for greater-than
  108. @code
  109. r0 = (a0 > b0) ? 0xffffffff : 0x0
  110. ...
  111. rN = (aN > bN) ? 0xffffffff : 0x0
  112. @endcode
  113. @par 128-bit version:
  114. @icost{SSE2-AVX2, 3-4}
  115. @icost{XOP, 1}
  116. @par 256-bit version:
  117. @icost{SSE2-AVX, 6-7}
  118. @icost{AVX2, 3-4}
  119. @icost{XOP, NEON, ALTIVEC, 2}
  120. */
  121. template<unsigned N, class E1, class E2> SIMDPP_INL
  122. mask_int32<N,expr_empty> cmp_gt(const uint32<N,E1>& a,
  123. const uint32<N,E2>& b)
  124. {
  125. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  126. }
  127. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int32, uint32)
  128. /** Compares the values of two signed int64 vectors for greater-than
  129. @code
  130. r0 = (a0 > b0) ? 0xffffffffffff : 0x0
  131. ...
  132. rN = (aN > bN) ? 0xffffffffffff : 0x0
  133. @endcode
  134. Supported since AVX2, NEON64. Not supported on ALTIVEC.
  135. */
  136. template<unsigned N, class E1, class E2> SIMDPP_INL
  137. mask_int64<N,expr_empty> cmp_gt(const int64<N,E1>& a,
  138. const int64<N,E2>& b)
  139. {
  140. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  141. }
  142. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int64, int64)
  143. /** Compares the values of two unsigned int64 vectors for greater-than
  144. @code
  145. r0 = (a0 > b0) ? 0xffffffffffff : 0x0
  146. ...
  147. rN = (aN > bN) ? 0xffffffffffff : 0x0
  148. @endcode
  149. Supported since AVX2, NEON64. Not supported on ALTIVEC.
  150. */
  151. template<unsigned N, class E1, class E2> SIMDPP_INL
  152. mask_int64<N,expr_empty> cmp_gt(const uint64<N,E1>& a,
  153. const uint64<N,E2>& b)
  154. {
  155. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  156. }
  157. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_int64, uint64)
  158. /** Compares the values of two float32x4 vectors for greater-than
  159. @code
  160. r0 = (a0 > b0) ? 0xffffffff : 0x0
  161. ...
  162. rN = (aN > bN) ? 0xffffffff : 0x0
  163. @endcode
  164. @par 256-bit version:
  165. @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
  166. */
  167. template<unsigned N, class E1, class E2>
  168. mask_float32<N,expr_empty> cmp_gt(const float32<N,E1>& a,
  169. const float32<N,E2>& b)
  170. {
  171. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  172. }
  173. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_float32, float32)
  174. /** Compares the values of two float64x2 vectors for greater-than
  175. @code
  176. r0 = (a0 > b0) ? 0xffffffffffffffff : 0x0
  177. ...
  178. rN = (aN > bN) ? 0xffffffffffffffff : 0x0
  179. @endcode
  180. @par 128-bit version:
  181. @novec{NEON, ALTIVEC}
  182. @par 256-bit version:
  183. @novec{NEON, ALTIVEC}
  184. @icost{SSE2-SSE4.1, 2}
  185. */
  186. template<unsigned N, class E1, class E2> SIMDPP_INL
  187. mask_float64<N,expr_empty> cmp_gt(const float64<N,E1>& a,
  188. const float64<N,E2>& b)
  189. {
  190. return detail::insn::i_cmp_gt(a.eval(), b.eval());
  191. }
  192. SIMDPP_SCALAR_ARG_IMPL_VEC(cmp_gt, mask_float64, float64)
  193. } // namespace SIMDPP_ARCH_NAMESPACE
  194. } // namespace simdpp
  195. #endif