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

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

Issue 2313863003: [arm] Improve Float(32|64)(Max|Min). (Closed)
Patch Set: Created 4 years, 3 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/arm/macro-assembler-arm.cc ('k') | test/cctest/test-assembler-arm.cc » ('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 f7e317e3bc6c252420be8b86fca764347dfa0edd..4fa615576dc6c980aae2583eb5a470218fed2a60 100644
--- a/src/compiler/arm/code-generator-arm.cc
+++ b/src/compiler/arm/code-generator-arm.cc
@@ -271,6 +271,37 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
UnwindingInfoWriter* const unwinding_info_writer_;
};
+template <typename T>
+class OutOfLineFloatMin final : public OutOfLineCode {
+ public:
+ OutOfLineFloatMin(CodeGenerator* gen, T result, T left, T right)
+ : OutOfLineCode(gen), result_(result), left_(left), right_(right) {}
+
+ void Generate() final { __ FloatMinOutOfLine(result_, left_, right_); }
+
+ private:
+ T const result_;
+ T const left_;
+ T const right_;
+};
+typedef OutOfLineFloatMin<SwVfpRegister> OutOfLineFloat32Min;
+typedef OutOfLineFloatMin<DwVfpRegister> OutOfLineFloat64Min;
+
+template <typename T>
+class OutOfLineFloatMax final : public OutOfLineCode {
+ public:
+ OutOfLineFloatMax(CodeGenerator* gen, T result, T left, T right)
+ : OutOfLineCode(gen), result_(result), left_(left), right_(right) {}
+
+ void Generate() final { __ FloatMaxOutOfLine(result_, left_, right_); }
+
+ private:
+ T const result_;
+ T const left_;
+ T const right_;
+};
+typedef OutOfLineFloatMax<SwVfpRegister> OutOfLineFloat32Max;
+typedef OutOfLineFloatMax<DwVfpRegister> OutOfLineFloat64Max;
Condition FlagsConditionToCondition(FlagsCondition condition) {
switch (condition) {
@@ -1377,145 +1408,59 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
case kArmFloat32Max: {
- FloatRegister left_reg = i.InputFloat32Register(0);
- FloatRegister right_reg = i.InputFloat32Register(1);
- FloatRegister result_reg = i.OutputFloat32Register();
- 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.
+ SwVfpRegister result = i.OutputFloat32Register();
+ SwVfpRegister left = i.InputFloat32Register(0);
+ SwVfpRegister right = i.InputFloat32Register(1);
+ if (left.is(right)) {
+ __ Move(result, left);
} else {
- __ b(ne, &return_left); // left == right != 0.
+ auto ool = new (zone()) OutOfLineFloat32Max(this, result, left, right);
+ __ FloatMax(result, left, right, ool->entry());
+ __ bind(ool->exit());
}
- // 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);
+ DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
}
case kArmFloat64Max: {
- 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.
+ DwVfpRegister result = i.OutputDoubleRegister();
+ DwVfpRegister left = i.InputDoubleRegister(0);
+ DwVfpRegister right = i.InputDoubleRegister(1);
+ if (left.is(right)) {
+ __ Move(result, left);
} else {
- __ b(ne, &return_left); // left == right != 0.
+ auto ool = new (zone()) OutOfLineFloat64Max(this, result, left, right);
+ __ FloatMax(result, left, right, ool->entry());
+ __ bind(ool->exit());
}
- // 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);
+ DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
}
case kArmFloat32Min: {
- FloatRegister left_reg = i.InputFloat32Register(0);
- FloatRegister right_reg = i.InputFloat32Register(1);
- FloatRegister result_reg = i.OutputFloat32Register();
- 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.
+ SwVfpRegister result = i.OutputFloat32Register();
+ SwVfpRegister left = i.InputFloat32Register(0);
+ SwVfpRegister right = i.InputFloat32Register(1);
+ if (left.is(right)) {
+ __ Move(result, left);
} else {
- __ b(ne, &return_left); // left == right != 0.
+ auto ool = new (zone()) OutOfLineFloat32Min(this, result, left, right);
+ __ FloatMin(result, left, right, ool->entry());
+ __ bind(ool->exit());
}
- // 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);
+ DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
}
case kArmFloat64Min: {
- 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.
+ DwVfpRegister result = i.OutputDoubleRegister();
+ DwVfpRegister left = i.InputDoubleRegister(0);
+ DwVfpRegister right = i.InputDoubleRegister(1);
+ if (left.is(right)) {
+ __ Move(result, left);
} else {
- __ b(ne, &return_left); // left == right != 0.
+ auto ool = new (zone()) OutOfLineFloat64Min(this, result, left, right);
+ __ FloatMin(result, left, right, ool->entry());
+ __ bind(ool->exit());
}
- // 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);
+ DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
}
case kArmFloat64SilenceNaN: {
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | test/cctest/test-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698