Non32bitOverflow.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 Test0Compound(a, b)
  6. {
  7. var t0, t1;
  8. t0 = a * b;
  9. d = t0 & a;
  10. return d;
  11. }
  12. function Test1Compound(a, b)
  13. {
  14. var t0, t1, t2, t3;
  15. t0 = a * b;
  16. t2 = t0 + a;
  17. d = t2 & a;
  18. return d;
  19. }
  20. function Test2Compound(a, b)
  21. {
  22. var t0, t1, t2, t3;
  23. t0 = a * b;
  24. t2 = t0 + a;
  25. t2 = t2 + b;
  26. d = t2 & a;
  27. return d;
  28. }
  29. function Test16Compound(a, b)
  30. {
  31. var t0, t1, t2, t3;
  32. t0 = a * b;
  33. // 8
  34. t2 = t0 + a;
  35. t2 = t2 + b;
  36. t2 = t2 + a;
  37. t2 = t2 + b;
  38. t2 = t2 + a;
  39. t2 = t2 + b;
  40. t2 = t2 + a;
  41. t2 = t2 + b;
  42. // 8
  43. t2 = t2 + a;
  44. t2 = t2 + b;
  45. t2 = t2 + a;
  46. t2 = t2 + b;
  47. t2 = t2 + a;
  48. t2 = t2 + b;
  49. t2 = t2 + a;
  50. t2 = t2 + b;
  51. d = t2 & a;
  52. return d;
  53. }
  54. function Test20Compound(a, b)
  55. {
  56. var t0, t1, t2, t3;
  57. t0 = a * b;
  58. // 8
  59. t2 = t0 + a;
  60. t2 = t2 + b;
  61. t2 = t2 + a;
  62. t2 = t2 + b;
  63. t2 = t2 + a;
  64. t2 = t2 + b;
  65. t2 = t2 + a;
  66. t2 = t2 + b;
  67. // 8
  68. t2 = t2 + a;
  69. t2 = t2 + b;
  70. t2 = t2 + a;
  71. t2 = t2 + b;
  72. t2 = t2 + a;
  73. t2 = t2 + b;
  74. t2 = t2 + a;
  75. t2 = t2 + b;
  76. // 4
  77. t2 = t2 + a;
  78. t2 = t2 + b;
  79. t2 = t2 + a;
  80. t2 = t2 + b;
  81. d = t2 & a;
  82. return d;
  83. }
  84. function Test32Compound(a, b)
  85. {
  86. var t0, t1, t2, t3;
  87. t0 = a * b;
  88. // 8
  89. t2 = t0 + a;
  90. t2 = t2 + b;
  91. t2 = t2 + a;
  92. t2 = t2 + b;
  93. t2 = t2 + a;
  94. t2 = t2 + b;
  95. t2 = t2 + a;
  96. t2 = t2 + b;
  97. // 8
  98. t2 = t2 + a;
  99. t2 = t2 + b;
  100. t2 = t2 + a;
  101. t2 = t2 + b;
  102. t2 = t2 + a;
  103. t2 = t2 + b;
  104. t2 = t2 + a;
  105. t2 = t2 + b;
  106. // 8
  107. t2 = t2 + a;
  108. t2 = t2 + b;
  109. t2 = t2 + a;
  110. t2 = t2 + b;
  111. t2 = t2 + a;
  112. t2 = t2 + b;
  113. t2 = t2 + a;
  114. t2 = t2 + b;
  115. // 8
  116. t2 = t2 + a;
  117. t2 = t2 + b;
  118. t2 = t2 + a;
  119. t2 = t2 + b;
  120. t2 = t2 + a;
  121. t2 = t2 + b;
  122. t2 = t2 + a;
  123. t2 = t2 + b;
  124. d = t2 & a;
  125. return d;
  126. }
  127. for (var i = 1; i < 2147483647; i+=3131313)
  128. {
  129. WScript.Echo("Test0Compound(" + -i + ", " + i + ") = " + Test0Compound(-i, i));
  130. WScript.Echo("Test0Compound(" + i + ", " + i + ") = " + Test0Compound(i, i));
  131. WScript.Echo("Test1Compound(" + -i + ", " + i + ") = " + Test1Compound(-i, i));
  132. WScript.Echo("Test1Compound(" + i + ", " + i + ") = " + Test1Compound(i, i));
  133. WScript.Echo("Test2Compound(" + -i + ", " + i + ") = " + Test2Compound(-i, i));
  134. WScript.Echo("Test2Compound(" + i + ", " + i + ") = " + Test2Compound(i, i));
  135. WScript.Echo("Test16Compound(" + -i + ", " + i + ") = " + Test16Compound(-i, i));
  136. WScript.Echo("Test16Compound(" + i + ", " + i + ") = " + Test16Compound(i, i));
  137. WScript.Echo("Test20Compound(" + -i + ", " + i + ") = " + Test20Compound(-i, i));
  138. WScript.Echo("Test20Compound(" + i + ", " + i + ") = " + Test20Compound(i, i));
  139. WScript.Echo("Test32Compound(" + -i + ", " + i + ") = " + Test32Compound(-i, i));
  140. WScript.Echo("Test32Compound(" + i + ", " + i + ") = " + Test32Compound(i, i));
  141. }
  142. WScript.Echo(Test1Compound(2147483647, 2147483647));
  143. WScript.Echo(Test1Compound(-2147483648, 2147483647));
  144. WScript.Echo(Test1Compound(2147483647, -2147483648));
  145. WScript.Echo(Test2Compound(2147483647, 2147483647));
  146. WScript.Echo(Test2Compound(-2147483648, 2147483647));
  147. WScript.Echo(Test2Compound(2147483647, -2147483648));
  148. WScript.Echo(Test16Compound(2147483647, 2147483647));
  149. WScript.Echo(Test16Compound(-2147483648, 2147483647));
  150. WScript.Echo(Test16Compound(2147483647, -2147483648));
  151. WScript.Echo(Test20Compound(2147483647, 2147483647));
  152. WScript.Echo(Test20Compound(-2147483648, 2147483647));
  153. WScript.Echo(Test20Compound(2147483647, -2147483648));
  154. WScript.Echo(Test32Compound(2147483647, 2147483647));
  155. WScript.Echo(Test32Compound(-2147483648, 2147483647));
  156. WScript.Echo(Test32Compound(2147483647, -2147483648));