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

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

Issue 1698903002: PPC: [crankshaft] Fix Math.min(0, 0) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/ppc/lithium-codegen-ppc.cc
diff --git a/src/crankshaft/ppc/lithium-codegen-ppc.cc b/src/crankshaft/ppc/lithium-codegen-ppc.cc
index cfe5042a3cac82aea2e27e48c2cbc70484a7b8d8..79891d2bafecdb049578ce59f0289ee39fde1f1c 100644
--- a/src/crankshaft/ppc/lithium-codegen-ppc.cc
+++ b/src/crankshaft/ppc/lithium-codegen-ppc.cc
@@ -1960,14 +1960,18 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
__ bne(&return_left); // left == right != 0.
// At this point, both left and right are either 0 or -0.
- // N.B. The following works because +0 + -0 == +0
if (operation == HMathMinMax::kMathMin) {
- // For min we want logical-or of sign bit: -(-L + -R)
+ // Min: The algorithm is: -((-L) + (-R)), which in case of L and R being
+ // different registers is most efficiently expressed as -((-L) - R).
__ fneg(left_reg, left_reg);
- __ fsub(result_reg, left_reg, right_reg);
+ if (left_reg.is(right_reg)) {
+ __ fadd(result_reg, left_reg, right_reg);
+ } else {
+ __ fsub(result_reg, left_reg, right_reg);
+ }
__ fneg(result_reg, result_reg);
} else {
- // For max we want logical-and of sign bit: (L + R)
+ // Max: The following works because +0 + -0 == +0
__ fadd(result_reg, left_reg, right_reg);
}
__ b(&done);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698