Index: test/mjsunit/lea-add.js |
diff --git a/test/mjsunit/compiler/multiply-sub.js b/test/mjsunit/lea-add.js |
similarity index 66% |
copy from test/mjsunit/compiler/multiply-sub.js |
copy to test/mjsunit/lea-add.js |
index 4793181d47a2b4a2b2390f5049758e651ef1ec1c..28a14947067b3be683eb19d7d3a39beeda60774f 100644 |
--- a/test/mjsunit/compiler/multiply-sub.js |
+++ b/test/mjsunit/lea-add.js |
@@ -26,31 +26,59 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
// Flags: --allow-natives-syntax |
-// Test expressions that can be computed with a multiply-add instruction. |
-function f(a, b, c) { |
- return a - b * c; |
+function a() { |
+ var sum = 0; |
+ for (var i = 0; i < 500; ++i) { |
+ sum = (i + sum) | 0; |
+ } |
+ return sum; |
} |
-function g(a, b, c) { |
- return a * b - c; |
+function b() { |
+ var sum = 0; |
+ for (var i = -500; i < 0; ++i) { |
+ sum = (i + sum) | 0; |
+ } |
+ return sum; |
} |
-function h(a, b, c, d) { |
- return a * b - c * d; |
+function c() { |
+ var sum = 0; |
+ for (var i = 0; i < 500; ++i) { |
+ sum += (i + -0x7fffffff) | 0; |
+ } |
+ return sum; |
} |
-assertEquals(-5.41, f(1.1, 2.1, 3.1)); |
-assertEquals(-5.41, f(1.1, 2.1, 3.1)); |
-%OptimizeFunctionOnNextCall(f); |
-assertEquals(-5.41, f(1.1, 2.1, 3.1)); |
+function d() { |
+ var sum = 0; |
+ for (var i = -501; i < 0; ++i) { |
+ sum += (i + 501) | 0; |
+ } |
+ return sum; |
+} |
+ |
+a(); |
+a(); |
+%OptimizeFunctionOnNextCall(a); |
+assertEquals(124750, a()); |
+assertEquals(124750, a()); |
+ |
+b(); |
+b(); |
+%OptimizeFunctionOnNextCall(b); |
+assertEquals(-125250, b()); |
+assertEquals(-125250, b()); |
-assertEquals(8.36, g(2.2, 3.3, -1.1)); |
-assertEquals(8.36, g(2.2, 3.3, -1.1)); |
-%OptimizeFunctionOnNextCall(g); |
-assertEquals(8.36, g(2.2, 3.3, -1.1)); |
+c(); |
+c(); |
+%OptimizeFunctionOnNextCall(c); |
+assertEquals(-1073741698750, c()); |
+assertEquals(-1073741698750, c()); |
-assertEquals(-1.5, h(1.5, 3.0, 12, 0.5)); |
-assertEquals(-1.5, h(1.5, 3.0, 12, 0.5)); |
-%OptimizeFunctionOnNextCall(h); |
-assertEquals(-1.5, h(1.5, 3.0, 12, 0.5)); |
+d(); |
+d(); |
+%OptimizeFunctionOnNextCall(d); |
+assertEquals(125250, d()); |
+assertEquals(125250, d()); |