Index: test/mjsunit/compiler/multiply-add.js |
diff --git a/test/mjsunit/compiler/regress-const.js b/test/mjsunit/compiler/multiply-add.js |
similarity index 61% |
copy from test/mjsunit/compiler/regress-const.js |
copy to test/mjsunit/compiler/multiply-add.js |
index aa55d0fd3ae17051a084a6bf28c2257f2abc8495..2b4304e845eecff29bf0c0a5c63c14700eb5290f 100644 |
--- a/test/mjsunit/compiler/regress-const.js |
+++ b/test/mjsunit/compiler/multiply-add.js |
@@ -1,4 +1,4 @@ |
-// Copyright 2011 the V8 project authors. All rights reserved. |
+// Copyright 2012 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -26,43 +26,44 @@ |
// 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. |
-// Test const initialization and assignments. |
-function f() { |
- var x = 42; |
- while (true) { |
- const y = x; |
- if (--x == 0) return y; |
- } |
+function f(a, b, c) { |
+ return a * b + c; |
} |
-function g() { |
- const x = 42; |
- x += 1; |
- return x; |
+function g(a, b, c) { |
+ return a + b * c; |
} |
-for (var i = 0; i < 5; i++) { |
- f(); |
- g(); |
+function h(a, b, c, d) { |
+ return a * b + c * d; |
} |
+assertEquals(5, f(1, 2, 3)); |
+assertEquals(5, f(1, 2, 3)); |
%OptimizeFunctionOnNextCall(f); |
-%OptimizeFunctionOnNextCall(g); |
- |
-assertEquals(42, f()); |
-assertEquals(42, g()); |
- |
- |
-function h(a, b) { |
- var r = a + b; |
- const X = 42; |
- return r + X; |
-} |
+assertEquals(5, f(1, 2, 3)); |
+assertEquals("2foo", f(1, 2, "foo")); |
+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)); |
-for (var i = 0; i < 5; i++) h(1,2); |
+assertEquals(7, g(1, 2, 3)); |
+assertEquals(7, g(1, 2, 3)); |
+%OptimizeFunctionOnNextCall(g); |
+assertEquals(7, g(1, 2, 3)); |
+assertEquals(8.36, g(1.1, 2.2, 3.3)); |
+assertEquals(8.36, g(1.1, 2.2, 3.3)); |
+%OptimizeFunctionOnNextCall(g); |
+assertEquals(8.36, g(1.1, 2.2, 3.3)); |
+assertEquals(14, h(1, 2, 3, 4)); |
+assertEquals(14, h(1, 2, 3, 4)); |
%OptimizeFunctionOnNextCall(h); |
- |
-assertEquals(45, h(1,2)); |
-assertEquals("foo742", h("foo", 7)); |
+assertEquals(14, h(1, 2, 3, 4)); |
+assertEquals(15.02, h(1.1, 2.1, 3.1, 4.1)); |
+assertEquals(15.02, h(1.1, 2.1, 3.1, 4.1)); |
+%OptimizeFunctionOnNextCall(h); |
+assertEquals(15.02, h(1.1, 2.1, 3.1, 4.1)); |