cmp_eq.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // This file is generated by tools/gen_operators.pl. CHANGES WILL BE OVERWRITTEN
  2. /* Copyright (C) 2013-2014 Povilas Kanapickas <[email protected]>
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef LIBSIMDPP_SIMDPP_CORE_CMP_EQ_OPERATOR_H
  8. #define LIBSIMDPP_SIMDPP_CORE_CMP_EQ_OPERATOR_H
  9. #ifndef LIBSIMDPP_SIMD_H
  10. #error "This file must be included through simd.h"
  11. #endif
  12. #include <simdpp/types.h>
  13. #include <simdpp/detail/insn/cmp_eq.h>
  14. #include <simdpp/core/detail/scalar_arg_impl.h>
  15. namespace simdpp {
  16. namespace SIMDPP_ARCH_NAMESPACE {
  17. /** Compares 8-bit values for equality.
  18. @code
  19. r0 = (a0 == b0) ? 0xff : 0x0
  20. ...
  21. rN = (aN == bN) ? 0xff : 0x0
  22. @endcode
  23. @par 256-bit version:
  24. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  25. */
  26. template<unsigned N, class V1, class V2> SIMDPP_INL
  27. mask_int8<N,expr_empty> operator==(const any_int8<N,V1>& a,
  28. const any_int8<N,V2>& b)
  29. {
  30. typename detail::get_expr2_nosign<V1, V2>::type ra, rb;
  31. ra = a.wrapped().eval();
  32. rb = b.wrapped().eval();
  33. return detail::insn::i_cmp_eq(ra, rb);
  34. }
  35. SIMDPP_SCALAR_ARG_IMPL_VEC_EXPR(operator==, mask_int8, any_int8)
  36. /** Compares 16-bit values for equality.
  37. @code
  38. r0 = (a0 == b0) ? 0xffff : 0x0
  39. ...
  40. rN = (aN == bN) ? 0xffff : 0x0
  41. @endcode
  42. @par 256-bit version:
  43. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  44. */
  45. template<unsigned N, class V1, class V2> SIMDPP_INL
  46. mask_int16<N,expr_empty> operator==(const any_int16<N,V1>& a,
  47. const any_int16<N,V2>& b)
  48. {
  49. typename detail::get_expr2_nosign<V1, V2>::type ra, rb;
  50. ra = a.wrapped().eval();
  51. rb = b.wrapped().eval();
  52. return detail::insn::i_cmp_eq(ra, rb);
  53. }
  54. SIMDPP_SCALAR_ARG_IMPL_VEC_EXPR(operator==, mask_int16, any_int16)
  55. /** Compares the values of two int32x4 vectors for equality
  56. @code
  57. r0 = (a0 == b0) ? 0xffffffff : 0x0
  58. ...
  59. rN = (aN == bN) ? 0xffffffff : 0x0
  60. @endcode
  61. @par 256-bit version:
  62. @icost{SSE2-AVX, NEON, ALTIVEC, 2}
  63. */
  64. template<unsigned N, class V1, class V2> SIMDPP_INL
  65. mask_int32<N,expr_empty> operator==(const any_int32<N,V1>& a,
  66. const any_int32<N,V2>& b)
  67. {
  68. typename detail::get_expr2_nosign<V1, V2>::type ra, rb;
  69. ra = a.wrapped().eval();
  70. rb = b.wrapped().eval();
  71. return detail::insn::i_cmp_eq(ra, rb);
  72. }
  73. SIMDPP_SCALAR_ARG_IMPL_VEC_EXPR(operator==, mask_int32, any_int32)
  74. /** Compares the values of two int64x2 vectors for equality
  75. @code
  76. r0 = (a0 == b0) ? 0xffffffffffffffff : 0x0
  77. ...
  78. rN = (aN == bN) ? 0xffffffffffffffff : 0x0
  79. @endcode
  80. @par 128-bit version:
  81. @icost{SSE2-SSSE3, 5}
  82. @icost{XOP, 1}
  83. @icost{NEON, 3}
  84. @icost{ALTIVEC, 3-4}
  85. @par 256-bit version:
  86. @icost{SSE2-SSSE3, AVX, 10}
  87. @icost{XOP, SSE4.1, 2}
  88. @icost{NEON, 6}
  89. @icost{ALTIVEC, 6-7}
  90. */
  91. template<unsigned N, class V1, class V2> SIMDPP_INL
  92. mask_int64<N,expr_empty> operator==(const any_int64<N,V1>& a,
  93. const any_int64<N,V2>& b)
  94. {
  95. typename detail::get_expr2_nosign<V1, V2>::type ra, rb;
  96. ra = a.wrapped().eval();
  97. rb = b.wrapped().eval();
  98. return detail::insn::i_cmp_eq(ra, rb);
  99. }
  100. SIMDPP_SCALAR_ARG_IMPL_VEC_EXPR(operator==, mask_int64, any_int64)
  101. /** Compares the values of two float32x4 vectors for equality
  102. @code
  103. r0 = (a0 == b0) ? 0xffffffff : 0x0
  104. ...
  105. rN = (aN == bN) ? 0xffffffff : 0x0
  106. @endcode
  107. @par 256-bit version:
  108. @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
  109. */
  110. template<unsigned N, class V1, class V2> SIMDPP_INL
  111. mask_float32<N,expr_empty> operator==(const any_float32<N,V1>& a,
  112. const any_float32<N,V2>& b)
  113. {
  114. return detail::insn::i_cmp_eq(a.wrapped().eval(), b.wrapped().eval());
  115. }
  116. SIMDPP_SCALAR_ARG_IMPL_VEC_EXPR(operator==, mask_float32, any_float32)
  117. /** Compares the values of two float64x2 vectors for equality
  118. @code
  119. r0 = (a0 == b0) ? 0xffffffffffffffff : 0x0
  120. ...
  121. rN = (aN == bN) ? 0xffffffffffffffff : 0x0
  122. @endcode
  123. @par 128-bit version:
  124. @novec{NEON, ALTIVEC}
  125. @par 256-bit version:
  126. @novec{NEON, ALTIVEC}
  127. @icost{SSE2-SSE4.1, 2}
  128. */
  129. template<unsigned N, class V1, class V2> SIMDPP_INL
  130. mask_float64<N,expr_empty> operator==(const any_float64<N,V1>& a,
  131. const any_float64<N,V2>& b)
  132. {
  133. return detail::insn::i_cmp_eq(a.wrapped().eval(), b.wrapped().eval());
  134. }
  135. SIMDPP_SCALAR_ARG_IMPL_VEC_EXPR(operator==, mask_float64, any_float64)
  136. } // namespace SIMDPP_ARCH_NAMESPACE
  137. } // namespace simdpp
  138. #endif