Commit c6abc94f authored by bradnelson's avatar bradnelson Committed by Commit bot

Allow negation of doubles in asm typer.

BUG= https://code.google.com/p/v8/issues/detail?id=4203
TEST=mjsunit/asm-wasm
R=titzer@chromium.org,aseemgarg@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1756693003

Cr-Commit-Position: refs/heads/master@{#34449}
parent 4f6c5108
...@@ -1258,6 +1258,14 @@ void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -1258,6 +1258,14 @@ void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
} }
IntersectResult(expr, cache_.kAsmDouble); IntersectResult(expr, cache_.kAsmDouble);
return; return;
} else if (expr->op() == Token::MUL && left_type->Is(cache_.kAsmDouble) &&
expr->right()->IsLiteral() &&
!expr->right()->AsLiteral()->raw_value()->ContainsDot() &&
expr->right()->AsLiteral()->raw_value()->AsNumber() == -1.0) {
// For unary -, expressed as x * -1
expr->right()->set_bounds(Bounds(cache_.kAsmDouble));
IntersectResult(expr, cache_.kAsmDouble);
return;
} else if (type->Is(cache_.kAsmFloat) && expr->op() != Token::MOD) { } else if (type->Is(cache_.kAsmFloat) && expr->op() != Token::MOD) {
if (left_intish != 0 || right_intish != 0) { if (left_intish != 0 || right_intish != 0) {
FAIL(expr, "float operation before required fround"); FAIL(expr, "float operation before required fround");
......
...@@ -2366,3 +2366,25 @@ TEST(StoreFloatFromDouble) { ...@@ -2366,3 +2366,25 @@ TEST(StoreFloatFromDouble) {
} }
CHECK_FUNC_TYPES_END CHECK_FUNC_TYPES_END
} }
TEST(NegateDouble) {
CHECK_FUNC_TYPES_BEGIN(
"function bar() { var x = 0.0; x = -x; }\n"
"function foo() { bar(); }") {
CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {
CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) {
CHECK_VAR(x, Bounds(cache.kAsmDouble));
CHECK_EXPR(Literal, Bounds(cache.kAsmDouble));
}
CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) {
CHECK_VAR(x, Bounds(cache.kAsmDouble));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) {
CHECK_VAR(x, Bounds(cache.kAsmDouble));
CHECK_EXPR(Literal, Bounds(cache.kAsmDouble));
}
}
}
CHECK_SKIP();
}
CHECK_FUNC_TYPES_END
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment