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

Unified Diff: src/compiler/arm/code-generator-arm.cc

Issue 2170343002: [turbofan] Change Float64Max/Float64Min to JavaScript semantics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips/mips64 ports. Created 4 years, 5 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 | src/compiler/arm/instruction-codes-arm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/arm/code-generator-arm.cc
diff --git a/src/compiler/arm/code-generator-arm.cc b/src/compiler/arm/code-generator-arm.cc
index fead058193ba27592e2549042353a84387088b3e..8f1e01f67540cdb45b7d39c2d42ecf484e68c0c2 100644
--- a/src/compiler/arm/code-generator-arm.cc
+++ b/src/compiler/arm/code-generator-arm.cc
@@ -1360,44 +1360,75 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vstr(i.InputDoubleRegister(0), i.InputOffset(1));
DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
- case kArmFloat32Max: {
- CpuFeatureScope scope(masm(), ARMv8);
- // (b < a) ? a : b
- SwVfpRegister a = i.InputFloatRegister(0);
- SwVfpRegister b = i.InputFloatRegister(1);
- SwVfpRegister result = i.OutputFloatRegister();
- __ VFPCompareAndSetFlags(a, b);
- __ vsel(gt, result, a, b);
- break;
- }
- case kArmFloat32Min: {
- CpuFeatureScope scope(masm(), ARMv8);
- // (a < b) ? a : b
- SwVfpRegister a = i.InputFloatRegister(0);
- SwVfpRegister b = i.InputFloatRegister(1);
- SwVfpRegister result = i.OutputFloatRegister();
- __ VFPCompareAndSetFlags(b, a);
- __ vsel(gt, result, a, b);
- break;
- }
case kArmFloat64Max: {
- CpuFeatureScope scope(masm(), ARMv8);
- // (b < a) ? a : b
- DwVfpRegister a = i.InputDoubleRegister(0);
- DwVfpRegister b = i.InputDoubleRegister(1);
- DwVfpRegister result = i.OutputDoubleRegister();
- __ VFPCompareAndSetFlags(a, b);
- __ vsel(gt, result, a, b);
+ DwVfpRegister left_reg = i.InputDoubleRegister(0);
+ DwVfpRegister right_reg = i.InputDoubleRegister(1);
+ DwVfpRegister result_reg = i.OutputDoubleRegister();
+ Label result_is_nan, return_left, return_right, check_zero, done;
+ __ VFPCompareAndSetFlags(left_reg, right_reg);
+ __ b(mi, &return_right);
+ __ b(gt, &return_left);
+ __ b(vs, &result_is_nan);
+ // Left equals right => check for -0.
+ __ VFPCompareAndSetFlags(left_reg, 0.0);
+ if (left_reg.is(result_reg) || right_reg.is(result_reg)) {
+ __ b(ne, &done); // left == right != 0.
+ } else {
+ __ b(ne, &return_left); // left == right != 0.
+ }
+ // At this point, both left and right are either 0 or -0.
+ // Since we operate on +0 and/or -0, vadd and vand have the same effect;
+ // the decision for vadd is easy because vand is a NEON instruction.
+ __ vadd(result_reg, left_reg, right_reg);
+ __ b(&done);
+ __ bind(&result_is_nan);
+ __ vadd(result_reg, left_reg, right_reg);
+ __ b(&done);
+ __ bind(&return_right);
+ __ Move(result_reg, right_reg);
+ if (!left_reg.is(result_reg)) __ b(&done);
+ __ bind(&return_left);
+ __ Move(result_reg, left_reg);
+ __ bind(&done);
break;
}
case kArmFloat64Min: {
- CpuFeatureScope scope(masm(), ARMv8);
- // (a < b) ? a : b
- DwVfpRegister a = i.InputDoubleRegister(0);
- DwVfpRegister b = i.InputDoubleRegister(1);
- DwVfpRegister result = i.OutputDoubleRegister();
- __ VFPCompareAndSetFlags(b, a);
- __ vsel(gt, result, a, b);
+ DwVfpRegister left_reg = i.InputDoubleRegister(0);
+ DwVfpRegister right_reg = i.InputDoubleRegister(1);
+ DwVfpRegister result_reg = i.OutputDoubleRegister();
+ Label result_is_nan, return_left, return_right, check_zero, done;
+ __ VFPCompareAndSetFlags(left_reg, right_reg);
+ __ b(mi, &return_left);
+ __ b(gt, &return_right);
+ __ b(vs, &result_is_nan);
+ // Left equals right => check for -0.
+ __ VFPCompareAndSetFlags(left_reg, 0.0);
+ if (left_reg.is(result_reg) || right_reg.is(result_reg)) {
+ __ b(ne, &done); // left == right != 0.
+ } else {
+ __ b(ne, &return_left); // left == right != 0.
+ }
+ // At this point, both left and right are either 0 or -0.
+ // We could use a single 'vorr' instruction here if we had NEON support.
+ // The algorithm is: -((-L) + (-R)), which in case of L and R being
+ // different registers is most efficiently expressed as -((-L) - R).
+ __ vneg(left_reg, left_reg);
+ if (left_reg.is(right_reg)) {
+ __ vadd(result_reg, left_reg, right_reg);
+ } else {
+ __ vsub(result_reg, left_reg, right_reg);
+ }
+ __ vneg(result_reg, result_reg);
+ __ b(&done);
+ __ bind(&result_is_nan);
+ __ vadd(result_reg, left_reg, right_reg);
+ __ b(&done);
+ __ bind(&return_right);
+ __ Move(result_reg, right_reg);
+ if (!left_reg.is(result_reg)) __ b(&done);
+ __ bind(&return_left);
+ __ Move(result_reg, left_reg);
+ __ bind(&done);
break;
}
case kArmFloat64SilenceNaN: {
« no previous file with comments | « no previous file | src/compiler/arm/instruction-codes-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698