SimdBool32x4OperationX86X64.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "RuntimeLanguagePch.h"
  6. #if _M_IX86 || _M_AMD64
  7. namespace Js
  8. {
  9. SIMDValue SIMDBool32x4Operation::OpBool32x4(bool x, bool y, bool z, bool w)
  10. {
  11. X86SIMDValue x86Result;
  12. x86Result.m128i_value = _mm_set_epi32(w * -1, z * -1, y * -1, x * -1);
  13. return X86SIMDValue::ToSIMDValue(x86Result);
  14. }
  15. SIMDValue SIMDBool32x4Operation::OpBool32x4(const SIMDValue& v)
  16. {
  17. // overload function with input parameter as SIMDValue for completeness
  18. SIMDValue result;
  19. result = v;
  20. return result;
  21. }
  22. // Unary Ops
  23. bool SIMDBool32x4Operation::OpAnyTrue(const SIMDValue& simd)
  24. {
  25. X86SIMDValue x86Simd = X86SIMDValue::ToX86SIMDValue(simd);
  26. int mask_8 = _mm_movemask_epi8(x86Simd.m128i_value); //latency 3, throughput 1
  27. return mask_8 != 0;
  28. }
  29. bool SIMDBool32x4Operation::OpAllTrue(const SIMDValue& simd)
  30. {
  31. X86SIMDValue x86Simd = X86SIMDValue::ToX86SIMDValue(simd);
  32. int mask_8 = _mm_movemask_epi8(x86Simd.m128i_value); //latency 3, throughput 1
  33. return mask_8 == 0xFFFF;
  34. }
  35. }
  36. #endif