Commit 189609e1 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Float32Abs and Float64Abs are supported by all backends.

The Float32Abs and Float64Abs operators are supported by all TurboFan
backends, so we no longer need the flags for them.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28310}
parent 43d53191
...@@ -1594,11 +1594,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1594,11 +1594,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::Flags flags =
MachineOperatorBuilder::kFloat32Abs |
MachineOperatorBuilder::kFloat64Abs |
MachineOperatorBuilder::kInt32DivIsSafe | MachineOperatorBuilder::kInt32DivIsSafe |
MachineOperatorBuilder::kUint32DivIsSafe; MachineOperatorBuilder::kUint32DivIsSafe;
if (CpuFeatures::IsSupported(ARMv8)) { if (CpuFeatures::IsSupported(ARMv8)) {
flags |= MachineOperatorBuilder::kFloat64RoundDown | flags |= MachineOperatorBuilder::kFloat64RoundDown |
MachineOperatorBuilder::kFloat64RoundTruncate | MachineOperatorBuilder::kFloat64RoundTruncate |
......
...@@ -1871,10 +1871,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1871,10 +1871,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
// static // static
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
return MachineOperatorBuilder::kFloat32Abs | return MachineOperatorBuilder::kFloat32Max |
MachineOperatorBuilder::kFloat32Max |
MachineOperatorBuilder::kFloat32Min | MachineOperatorBuilder::kFloat32Min |
MachineOperatorBuilder::kFloat64Abs |
MachineOperatorBuilder::kFloat64Max | MachineOperatorBuilder::kFloat64Max |
MachineOperatorBuilder::kFloat64Min | MachineOperatorBuilder::kFloat64Min |
MachineOperatorBuilder::kFloat64RoundDown | MachineOperatorBuilder::kFloat64RoundDown |
......
...@@ -58,8 +58,7 @@ Reduction CommonOperatorReducer::ReducePhi(Node* node) { ...@@ -58,8 +58,7 @@ Reduction CommonOperatorReducer::ReducePhi(Node* node) {
if (cond->opcode() == IrOpcode::kFloat32LessThan) { if (cond->opcode() == IrOpcode::kFloat32LessThan) {
Float32BinopMatcher mcond(cond); Float32BinopMatcher mcond(cond);
if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
vfalse->opcode() == IrOpcode::kFloat32Sub && vfalse->opcode() == IrOpcode::kFloat32Sub) {
machine()->HasFloat32Abs()) {
Float32BinopMatcher mvfalse(vfalse); Float32BinopMatcher mvfalse(vfalse);
if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
return Change(node, machine()->Float32Abs(), vtrue); return Change(node, machine()->Float32Abs(), vtrue);
...@@ -75,8 +74,7 @@ Reduction CommonOperatorReducer::ReducePhi(Node* node) { ...@@ -75,8 +74,7 @@ Reduction CommonOperatorReducer::ReducePhi(Node* node) {
} else if (cond->opcode() == IrOpcode::kFloat64LessThan) { } else if (cond->opcode() == IrOpcode::kFloat64LessThan) {
Float64BinopMatcher mcond(cond); Float64BinopMatcher mcond(cond);
if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
vfalse->opcode() == IrOpcode::kFloat64Sub && vfalse->opcode() == IrOpcode::kFloat64Sub) {
machine()->HasFloat64Abs()) {
Float64BinopMatcher mvfalse(vfalse); Float64BinopMatcher mvfalse(vfalse);
if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
return Change(node, machine()->Float64Abs(), vtrue); return Change(node, machine()->Float64Abs(), vtrue);
...@@ -117,8 +115,7 @@ Reduction CommonOperatorReducer::ReduceSelect(Node* node) { ...@@ -117,8 +115,7 @@ Reduction CommonOperatorReducer::ReduceSelect(Node* node) {
case IrOpcode::kFloat32LessThan: { case IrOpcode::kFloat32LessThan: {
Float32BinopMatcher mcond(cond); Float32BinopMatcher mcond(cond);
if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
vfalse->opcode() == IrOpcode::kFloat32Sub && vfalse->opcode() == IrOpcode::kFloat32Sub) {
machine()->HasFloat32Abs()) {
Float32BinopMatcher mvfalse(vfalse); Float32BinopMatcher mvfalse(vfalse);
if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
return Change(node, machine()->Float32Abs(), vtrue); return Change(node, machine()->Float32Abs(), vtrue);
...@@ -136,8 +133,7 @@ Reduction CommonOperatorReducer::ReduceSelect(Node* node) { ...@@ -136,8 +133,7 @@ Reduction CommonOperatorReducer::ReduceSelect(Node* node) {
case IrOpcode::kFloat64LessThan: { case IrOpcode::kFloat64LessThan: {
Float64BinopMatcher mcond(cond); Float64BinopMatcher mcond(cond);
if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
vfalse->opcode() == IrOpcode::kFloat64Sub && vfalse->opcode() == IrOpcode::kFloat64Sub) {
machine()->HasFloat64Abs()) {
Float64BinopMatcher mvfalse(vfalse); Float64BinopMatcher mvfalse(vfalse);
if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
return Change(node, machine()->Float64Abs(), vtrue); return Change(node, machine()->Float64Abs(), vtrue);
......
...@@ -1306,10 +1306,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1306,10 +1306,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::Flags flags =
MachineOperatorBuilder::kFloat32Abs |
MachineOperatorBuilder::kFloat32Max | MachineOperatorBuilder::kFloat32Max |
MachineOperatorBuilder::kFloat32Min | MachineOperatorBuilder::kFloat32Min |
MachineOperatorBuilder::kFloat64Abs |
MachineOperatorBuilder::kFloat64Max | MachineOperatorBuilder::kFloat64Max |
MachineOperatorBuilder::kFloat64Min | MachineOperatorBuilder::kFloat64Min |
MachineOperatorBuilder::kWord32ShiftIsSafe; MachineOperatorBuilder::kWord32ShiftIsSafe;
......
...@@ -74,18 +74,16 @@ class MachineOperatorBuilder final : public ZoneObject { ...@@ -74,18 +74,16 @@ class MachineOperatorBuilder final : public ZoneObject {
// for operations that are unsupported by some back-ends. // for operations that are unsupported by some back-ends.
enum Flag { enum Flag {
kNoFlags = 0u, kNoFlags = 0u,
kFloat32Abs = 1u << 0, kFloat32Max = 1u << 0,
kFloat32Max = 1u << 1, kFloat32Min = 1u << 1,
kFloat32Min = 1u << 2, kFloat64Max = 1u << 2,
kFloat64Abs = 1u << 3, kFloat64Min = 1u << 3,
kFloat64Max = 1u << 4, kFloat64RoundDown = 1u << 4,
kFloat64Min = 1u << 5, kFloat64RoundTruncate = 1u << 5,
kFloat64RoundDown = 1u << 6, kFloat64RoundTiesAway = 1u << 6,
kFloat64RoundTruncate = 1u << 7, kInt32DivIsSafe = 1u << 7,
kFloat64RoundTiesAway = 1u << 8, kUint32DivIsSafe = 1u << 8,
kInt32DivIsSafe = 1u << 9, kWord32ShiftIsSafe = 1u << 9
kUint32DivIsSafe = 1u << 10,
kWord32ShiftIsSafe = 1u << 11
}; };
typedef base::Flags<Flag, unsigned> Flags; typedef base::Flags<Flag, unsigned> Flags;
...@@ -201,11 +199,9 @@ class MachineOperatorBuilder final : public ZoneObject { ...@@ -201,11 +199,9 @@ class MachineOperatorBuilder final : public ZoneObject {
// Floating point abs complying to IEEE 754 (single-precision). // Floating point abs complying to IEEE 754 (single-precision).
const Operator* Float32Abs(); const Operator* Float32Abs();
bool HasFloat32Abs() const { return flags_ & kFloat32Abs; }
// Floating point abs complying to IEEE 754 (double-precision). // Floating point abs complying to IEEE 754 (double-precision).
const Operator* Float64Abs(); const Operator* Float64Abs();
bool HasFloat64Abs() const { return flags_ & kFloat64Abs; }
// Floating point rounding. // Floating point rounding.
const Operator* Float64RoundDown(); const Operator* Float64RoundDown();
......
...@@ -1058,9 +1058,7 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1058,9 +1058,7 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
// static // static
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags;
MachineOperatorBuilder::kFloat32Abs | MachineOperatorBuilder::kFloat64Abs;
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) && if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
IsFp64Mode()) { IsFp64Mode()) {
flags |= MachineOperatorBuilder::kFloat64RoundDown | flags |= MachineOperatorBuilder::kFloat64RoundDown |
......
...@@ -1271,9 +1271,7 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1271,9 +1271,7 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
// static // static
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
return MachineOperatorBuilder::kFloat32Abs | return MachineOperatorBuilder::kFloat64RoundDown |
MachineOperatorBuilder::kFloat64Abs |
MachineOperatorBuilder::kFloat64RoundDown |
MachineOperatorBuilder::kFloat64RoundTruncate; MachineOperatorBuilder::kFloat64RoundTruncate;
} }
......
...@@ -1623,10 +1623,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1623,10 +1623,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
// static // static
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
return MachineOperatorBuilder::kFloat32Abs | return MachineOperatorBuilder::kFloat32Max |
MachineOperatorBuilder::kFloat32Max |
MachineOperatorBuilder::kFloat32Min | MachineOperatorBuilder::kFloat32Min |
MachineOperatorBuilder::kFloat64Abs |
MachineOperatorBuilder::kFloat64Max | MachineOperatorBuilder::kFloat64Max |
MachineOperatorBuilder::kFloat64Min | MachineOperatorBuilder::kFloat64Min |
MachineOperatorBuilder::kFloat64RoundDown | MachineOperatorBuilder::kFloat64RoundDown |
......
...@@ -1619,10 +1619,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ...@@ -1619,10 +1619,8 @@ void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::Flags flags =
MachineOperatorBuilder::kFloat32Abs |
MachineOperatorBuilder::kFloat32Max | MachineOperatorBuilder::kFloat32Max |
MachineOperatorBuilder::kFloat32Min | MachineOperatorBuilder::kFloat32Min |
MachineOperatorBuilder::kFloat64Abs |
MachineOperatorBuilder::kFloat64Max | MachineOperatorBuilder::kFloat64Max |
MachineOperatorBuilder::kFloat64Min | MachineOperatorBuilder::kFloat64Min |
MachineOperatorBuilder::kWord32ShiftIsSafe; MachineOperatorBuilder::kWord32ShiftIsSafe;
......
...@@ -4950,7 +4950,6 @@ TEST(RunFloat32Abs) { ...@@ -4950,7 +4950,6 @@ TEST(RunFloat32Abs) {
float input = -1.0; float input = -1.0;
float result = 0.0; float result = 0.0;
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
if (!m.machine()->HasFloat32Abs()) return;
m.StoreToPointer(&result, kMachFloat32, m.StoreToPointer(&result, kMachFloat32,
m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32))); m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32)));
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
...@@ -4967,7 +4966,6 @@ TEST(RunFloat64Abs) { ...@@ -4967,7 +4966,6 @@ TEST(RunFloat64Abs) {
double input = -1.0; double input = -1.0;
double result = 0.0; double result = 0.0;
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
if (!m.machine()->HasFloat64Abs()) return;
m.StoreToPointer(&result, kMachFloat64, m.StoreToPointer(&result, kMachFloat64,
m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64))); m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64)));
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
......
...@@ -120,7 +120,7 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Abs) { ...@@ -120,7 +120,7 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Abs) {
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
Node* phi = Node* phi =
graph()->NewNode(common()->Phi(kMachFloat32, 2), vtrue, vfalse, merge); graph()->NewNode(common()->Phi(kMachFloat32, 2), vtrue, vfalse, merge);
Reduction r = Reduce(phi, MachineOperatorBuilder::kFloat32Abs); Reduction r = Reduce(phi);
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat32Abs(p0)); EXPECT_THAT(r.replacement(), IsFloat32Abs(p0));
} }
...@@ -138,7 +138,7 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Abs) { ...@@ -138,7 +138,7 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Abs) {
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
Node* phi = Node* phi =
graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge);
Reduction r = Reduce(phi, MachineOperatorBuilder::kFloat64Abs); Reduction r = Reduce(phi);
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); EXPECT_THAT(r.replacement(), IsFloat64Abs(p0));
} }
...@@ -250,7 +250,7 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Abs) { ...@@ -250,7 +250,7 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Abs) {
Node* select = Node* select =
graph()->NewNode(common()->Select(kMachFloat32), check, p0, graph()->NewNode(common()->Select(kMachFloat32), check, p0,
graph()->NewNode(machine()->Float32Sub(), c0, p0)); graph()->NewNode(machine()->Float32Sub(), c0, p0));
Reduction r = Reduce(select, MachineOperatorBuilder::kFloat32Abs); Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat32Abs(p0)); EXPECT_THAT(r.replacement(), IsFloat32Abs(p0));
} }
...@@ -263,7 +263,7 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Abs) { ...@@ -263,7 +263,7 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Abs) {
Node* select = Node* select =
graph()->NewNode(common()->Select(kMachFloat64), check, p0, graph()->NewNode(common()->Select(kMachFloat64), check, p0,
graph()->NewNode(machine()->Float64Sub(), c0, p0)); graph()->NewNode(machine()->Float64Sub(), c0, p0));
Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Abs); Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed()); ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); EXPECT_THAT(r.replacement(), IsFloat64Abs(p0));
} }
......
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