Commit 208415d6 authored by bmeurer's avatar bmeurer Committed by Commit bot

[stubs] Allow branch combining for Smi overflow checks.

The value projection of the Add/SubWithOverflow must be scheduled after
the Branch that dispatches based on overflow in order for the
instruction selector to be able to combine the addition/subtraction with
the branching.

R=epertoso@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35011}
parent b8862ac2
...@@ -555,11 +555,11 @@ void AddStub::GenerateAssembly(compiler::CodeStubAssembler* assembler) const { ...@@ -555,11 +555,11 @@ void AddStub::GenerateAssembly(compiler::CodeStubAssembler* assembler) const {
assembler->Bind(&if_rhsissmi); assembler->Bind(&if_rhsissmi);
{ {
// TODO(bmeurer): Properly fuse Int64AddWithOverflow on x64 // Try fast Smi addition first.
Node* pair = assembler->SmiAddWithOverflow(lhs, rhs); Node* pair = assembler->SmiAddWithOverflow(lhs, rhs);
Node* result = assembler->Projection(0, pair);
Node* overflow = assembler->Projection(1, pair); Node* overflow = assembler->Projection(1, pair);
// Check if the Smi additon overflowed.
Label if_overflow(assembler), if_notoverflow(assembler); Label if_overflow(assembler), if_notoverflow(assembler);
assembler->Branch(overflow, &if_overflow, &if_notoverflow); assembler->Branch(overflow, &if_overflow, &if_notoverflow);
...@@ -571,7 +571,7 @@ void AddStub::GenerateAssembly(compiler::CodeStubAssembler* assembler) const { ...@@ -571,7 +571,7 @@ void AddStub::GenerateAssembly(compiler::CodeStubAssembler* assembler) const {
} }
assembler->Bind(&if_notoverflow); assembler->Bind(&if_notoverflow);
assembler->Return(result); assembler->Return(assembler->Projection(0, pair));
} }
assembler->Bind(&if_rhsisnotsmi); assembler->Bind(&if_rhsisnotsmi);
...@@ -919,7 +919,6 @@ void SubtractStub::GenerateAssembly( ...@@ -919,7 +919,6 @@ void SubtractStub::GenerateAssembly(
{ {
// Try a fast Smi subtraction first. // Try a fast Smi subtraction first.
Node* pair = assembler->SmiSubWithOverflow(lhs, rhs); Node* pair = assembler->SmiSubWithOverflow(lhs, rhs);
Node* result = assembler->Projection(0, pair);
Node* overflow = assembler->Projection(1, pair); Node* overflow = assembler->Projection(1, pair);
// Check if the Smi subtraction overflowed. // Check if the Smi subtraction overflowed.
...@@ -935,7 +934,7 @@ void SubtractStub::GenerateAssembly( ...@@ -935,7 +934,7 @@ void SubtractStub::GenerateAssembly(
} }
assembler->Bind(&if_notoverflow); assembler->Bind(&if_notoverflow);
assembler->Return(result); assembler->Return(assembler->Projection(0, pair));
} }
assembler->Bind(&if_rhsisnotsmi); assembler->Bind(&if_rhsisnotsmi);
......
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