testMul.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function equal(a, b) {
  6. if (a == b) {
  7. print("Correct");
  8. } else {
  9. print(">> Fail!");
  10. }
  11. }
  12. function testMul() {
  13. print("Int32x4 mul");
  14. var a = SIMD.Int32x4(0xFFFFFFFF, 0xFFFFFFFF, 0x80000000, 0x0);
  15. var b = SIMD.Int32x4(0x1, 0xFFFFFFFF, 0x80000000, 0xFFFFFFFF);
  16. var c = SIMD.Int32x4.mul(a, b);
  17. equal(-1, SIMD.Int32x4.extractLane(c, 0));
  18. equal(0x1, SIMD.Int32x4.extractLane(c, 1));
  19. equal(0x0, SIMD.Int32x4.extractLane(c, 2));
  20. equal(0x0, SIMD.Int32x4.extractLane(c, 3));
  21. var d = SIMD.Int32x4(4, 3, 2, 1);
  22. var e = SIMD.Int32x4(10, 20, 30, 40);
  23. var f = SIMD.Int32x4.mul(d, e);
  24. equal(40, SIMD.Int32x4.extractLane(f, 0));
  25. equal(60, SIMD.Int32x4.extractLane(f, 1));
  26. equal(60, SIMD.Int32x4.extractLane(f, 2));
  27. equal(40, SIMD.Int32x4.extractLane(f, 3));
  28. }
  29. testMul();
  30. testMul();
  31. testMul();
  32. testMul();
  33. testMul();
  34. testMul();
  35. testMul();
  36. testMul();