Index: test/mjsunit/compiler/dead-code6.js |
diff --git a/test/mjsunit/regress/regress-1563.js b/test/mjsunit/compiler/dead-code6.js |
similarity index 65% |
copy from test/mjsunit/regress/regress-1563.js |
copy to test/mjsunit/compiler/dead-code6.js |
index 884b12595a6d7bc41c4bcad94c014b9379241811..ec9b8433ddd72187b3f9dab70baf2399fac0cdb2 100644 |
--- a/test/mjsunit/regress/regress-1563.js |
+++ b/test/mjsunit/compiler/dead-code6.js |
@@ -26,19 +26,48 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
// Flags: --allow-natives-syntax |
+// Test some dead code elimination scenarios |
-obj = new Uint8ClampedArray(10); |
+function dead1(x, y) { |
+ var a = x | 0, b = y | 0; |
+ a * b; |
+ a << b; |
+ a >> b; |
+ a >>> b; |
+ a | b; |
+ a & b; |
+ a ^ b; |
+ return x; |
+} |
+ |
+function dead2(x, y) { |
+ var a = x | 0, b = y | 0; |
+ (a | 0) * b; |
+ (a | 0) << b; |
+ (a | 0) >> b; |
+ (a | 0) >>> b; |
+ (a | 0) | b; |
+ (a | 0) & b; |
+ (a | 0) ^ b; |
+ return x; |
+} |
-// Test that undefined gets properly clamped in Crankshafted pixel array |
-// assignments. |
-function set_pixel(obj, arg) { |
- obj[0] = arg; |
+function dead3(a, b) { |
+ a == 2 ? (a * b) : (b * a); // dead |
+ return a; |
} |
-set_pixel(obj, 1.5); |
-set_pixel(obj, NaN); |
-%OptimizeFunctionOnNextCall(set_pixel); |
-set_pixel(obj, undefined); |
-set_pixel(obj, undefined); |
+assertTrue(dead1(33, 32) == 33); |
+assertTrue(dead1(33, 32) == 33); |
+%OptimizeFunctionOnNextCall(dead1); |
+assertTrue(dead1(33, 32) == 33); |
+ |
+assertTrue(dead2(34, 11) == 34); |
+assertTrue(dead2(34, 11) == 34); |
+%OptimizeFunctionOnNextCall(dead2); |
+assertTrue(dead2(34, 11) == 34); |
-assertEquals(0, obj[0]); |
+assertTrue(dead3(35, 12) == 35); |
+assertTrue(dead3(35, 12) == 35); |
+%OptimizeFunctionOnNextCall(dead3); |
+assertTrue(dead3(35, 12) == 35); |