| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --allow-natives-syntax | 5 // Flags: --allow-natives-syntax |
| 6 | 6 |
| 7 // For TurboFan, make sure we can eliminate the -0 return value check | 7 // For TurboFan, make sure we can eliminate the -0 return value check |
| 8 // by recognizing a constant value. | 8 // by recognizing a constant value. |
| 9 function gotaconstant(y) { return 15 * y; } | 9 function gotaconstant(y) { return 15 * y; } |
| 10 assertEquals(45, gotaconstant(3)); | 10 assertEquals(45, gotaconstant(3)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 assertEquals(-0, test(-3, 0)); | 29 assertEquals(-0, test(-3, 0)); |
| 30 assertEquals(-0, test(0, -0)); | 30 assertEquals(-0, test(0, -0)); |
| 31 | 31 |
| 32 | 32 |
| 33 const SMI_MAX = (1 << 29) - 1 + (1 << 29); // Create without overflowing. | 33 const SMI_MAX = (1 << 29) - 1 + (1 << 29); // Create without overflowing. |
| 34 const SMI_MIN = -SMI_MAX - 1; // Create without overflowing. | 34 const SMI_MIN = -SMI_MAX - 1; // Create without overflowing. |
| 35 | 35 |
| 36 // multiply by 3 to avoid compiler optimizations that convert 2*x to x + x. | 36 // multiply by 3 to avoid compiler optimizations that convert 2*x to x + x. |
| 37 assertEquals(SMI_MAX + SMI_MAX + SMI_MAX, test(SMI_MAX, 3)); | 37 assertEquals(SMI_MAX + SMI_MAX + SMI_MAX, test(SMI_MAX, 3)); |
| 38 |
| 39 // Verify that strength reduction will reduce the -0 check quite a bit |
| 40 // if we have a negative integer constant. |
| 41 function negtest(y) { return -3 * y; } |
| 42 assertEquals(-12, negtest(4)); |
| 43 assertEquals(-12, negtest(4)); |
| 44 %OptimizeFunctionOnNextCall(negtest); |
| 45 negtest(4); |
| 46 |
| OLD | NEW |