Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: src/crankshaft/mips64/lithium-codegen-mips64.cc

Issue 1695283002: [crankshaft][arm][mips] Fix Math.min(0, 0) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips64 too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crankshaft/mips/lithium-codegen-mips.cc ('k') | test/mjsunit/regress/math-min.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/mips64/lithium-codegen-mips64.cc
diff --git a/src/crankshaft/mips64/lithium-codegen-mips64.cc b/src/crankshaft/mips64/lithium-codegen-mips64.cc
index ab73d1072c97d6801850bf20458bac5a2f21196e..ba3b62d649c78bd1887672152feb0c68a28e713c 100644
--- a/src/crankshaft/mips64/lithium-codegen-mips64.cc
+++ b/src/crankshaft/mips64/lithium-codegen-mips64.cc
@@ -1906,8 +1906,14 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
__ BranchF(&return_left, NULL, ne, left_reg, kDoubleRegZero);
// At this point, both left and right are either 0 or -0.
if (operation == HMathMinMax::kMathMin) {
+ // The algorithm is: -((-L) + (-R)), which in case of L and R being
+ // different registers is most efficiently expressed as -((-L) - R).
__ neg_d(left_reg, left_reg);
- __ sub_d(result_reg, left_reg, right_reg);
+ if (left_reg.is(right_reg)) {
+ __ add_d(result_reg, left_reg, right_reg);
+ } else {
+ __ sub_d(result_reg, left_reg, right_reg);
+ }
__ neg_d(result_reg, result_reg);
} else {
__ add_d(result_reg, left_reg, right_reg);
« no previous file with comments | « src/crankshaft/mips/lithium-codegen-mips.cc ('k') | test/mjsunit/regress/math-min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698