Commit 44910725 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Fix RedundancyElimination and add more test coverage.

Make the RedundancyElimination handle all simplified operators that are
listed in the SIMPLIFIED_CHECKED_OP_LIST, and fix a couple of bugs and
oversights in the code. This also adds a lot of test coverage for all
the cases that we care about in RedundancyElimination (with respect to
Check/Checked simplified operators).

Bug: v8:8015
Change-Id: I57d29113389841b09abcd013313bf5dd1c67735f
Reviewed-on: https://chromium-review.googlesource.com/1233655Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56032}
parent 196874aa
...@@ -32,23 +32,9 @@ Reduction RedundancyElimination::Reduce(Node* node) { ...@@ -32,23 +32,9 @@ Reduction RedundancyElimination::Reduce(Node* node) {
case IrOpcode::kCheckSmi: case IrOpcode::kCheckSmi:
case IrOpcode::kCheckString: case IrOpcode::kCheckString:
case IrOpcode::kCheckSymbol: case IrOpcode::kCheckSymbol:
case IrOpcode::kCheckedFloat64ToInt32: #define SIMPLIFIED_CHECKED_OP(Opcode) case IrOpcode::k##Opcode:
case IrOpcode::kCheckedInt32Add: SIMPLIFIED_CHECKED_OP_LIST(SIMPLIFIED_CHECKED_OP)
case IrOpcode::kCheckedInt32Div: #undef SIMPLIFIED_CHECKED_OP
case IrOpcode::kCheckedInt32Mod:
case IrOpcode::kCheckedInt32Mul:
case IrOpcode::kCheckedInt32Sub:
case IrOpcode::kCheckedInt32ToTaggedSigned:
case IrOpcode::kCheckedTaggedSignedToInt32:
case IrOpcode::kCheckedTaggedToFloat64:
case IrOpcode::kCheckedTaggedToInt32:
case IrOpcode::kCheckedTaggedToTaggedPointer:
case IrOpcode::kCheckedTaggedToTaggedSigned:
case IrOpcode::kCheckedTruncateTaggedToWord32:
case IrOpcode::kCheckedUint32Div:
case IrOpcode::kCheckedUint32Mod:
case IrOpcode::kCheckedUint32ToInt32:
case IrOpcode::kCheckedUint32ToTaggedSigned:
return ReduceCheckNode(node); return ReduceCheckNode(node);
case IrOpcode::kSpeculativeNumberAdd: case IrOpcode::kSpeculativeNumberAdd:
case IrOpcode::kSpeculativeNumberSubtract: case IrOpcode::kSpeculativeNumberSubtract:
...@@ -140,6 +126,12 @@ bool CheckSubsumes(Node const* a, Node const* b) { ...@@ -140,6 +126,12 @@ bool CheckSubsumes(Node const* a, Node const* b) {
if (a->opcode() == IrOpcode::kCheckInternalizedString && if (a->opcode() == IrOpcode::kCheckInternalizedString &&
b->opcode() == IrOpcode::kCheckString) { b->opcode() == IrOpcode::kCheckString) {
// CheckInternalizedString(node) implies CheckString(node) // CheckInternalizedString(node) implies CheckString(node)
} else if (a->opcode() == IrOpcode::kCheckSmi &&
b->opcode() == IrOpcode::kCheckNumber) {
// CheckSmi(node) implies CheckNumber(node)
} else if (a->opcode() == IrOpcode::kCheckedTaggedSignedToInt32 &&
b->opcode() == IrOpcode::kCheckedTaggedToInt32) {
// CheckedTaggedSignedToInt32(node) implies CheckedTaggedToInt32(node)
} else if (a->opcode() != b->opcode()) { } else if (a->opcode() != b->opcode()) {
return false; return false;
} else { } else {
...@@ -150,11 +142,15 @@ bool CheckSubsumes(Node const* a, Node const* b) { ...@@ -150,11 +142,15 @@ bool CheckSubsumes(Node const* a, Node const* b) {
case IrOpcode::kCheckNumber: case IrOpcode::kCheckNumber:
break; break;
case IrOpcode::kCheckedInt32ToTaggedSigned: case IrOpcode::kCheckedInt32ToTaggedSigned:
case IrOpcode::kCheckedInt64ToInt32:
case IrOpcode::kCheckedInt64ToTaggedSigned:
case IrOpcode::kCheckedTaggedSignedToInt32: case IrOpcode::kCheckedTaggedSignedToInt32:
case IrOpcode::kCheckedTaggedToTaggedPointer: case IrOpcode::kCheckedTaggedToTaggedPointer:
case IrOpcode::kCheckedTaggedToTaggedSigned: case IrOpcode::kCheckedTaggedToTaggedSigned:
case IrOpcode::kCheckedUint32ToInt32: case IrOpcode::kCheckedUint32ToInt32:
case IrOpcode::kCheckedUint32ToTaggedSigned: case IrOpcode::kCheckedUint32ToTaggedSigned:
case IrOpcode::kCheckedUint64ToInt32:
case IrOpcode::kCheckedUint64ToTaggedSigned:
break; break;
case IrOpcode::kCheckedFloat64ToInt32: case IrOpcode::kCheckedFloat64ToInt32:
case IrOpcode::kCheckedTaggedToInt32: { case IrOpcode::kCheckedTaggedToInt32: {
...@@ -167,6 +163,20 @@ bool CheckSubsumes(Node const* a, Node const* b) { ...@@ -167,6 +163,20 @@ bool CheckSubsumes(Node const* a, Node const* b) {
} }
break; break;
} }
case IrOpcode::kCheckedTaggedToFloat64:
case IrOpcode::kCheckedTruncateTaggedToWord32: {
CheckTaggedInputParameters const& ap =
CheckTaggedInputParametersOf(a->op());
CheckTaggedInputParameters const& bp =
CheckTaggedInputParametersOf(b->op());
// {a} subsumes {b} if the modes are either the same, or {a} checks
// for Number, in which case {b} will be subsumed no matter what.
if (ap.mode() != bp.mode() &&
ap.mode() != CheckTaggedInputMode::kNumber) {
return false;
}
break;
}
default: default:
DCHECK(!IsCheckedWithFeedback(a->op())); DCHECK(!IsCheckedWithFeedback(a->op()));
return false; return false;
......
...@@ -11,7 +11,7 @@ namespace v8 { ...@@ -11,7 +11,7 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
class RedundancyElimination final : public AdvancedReducer { class V8_EXPORT_PRIVATE RedundancyElimination final : public AdvancedReducer {
public: public:
RedundancyElimination(Editor* editor, Zone* zone); RedundancyElimination(Editor* editor, Zone* zone);
~RedundancyElimination() final; ~RedundancyElimination() final;
......
...@@ -228,7 +228,7 @@ enum class CheckTaggedInputMode : uint8_t { ...@@ -228,7 +228,7 @@ enum class CheckTaggedInputMode : uint8_t {
size_t hash_value(CheckTaggedInputMode); size_t hash_value(CheckTaggedInputMode);
std::ostream& operator<<(std::ostream&, CheckTaggedInputMode); V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, CheckTaggedInputMode);
class CheckTaggedInputParameters { class CheckTaggedInputParameters {
public: public:
......
...@@ -40,7 +40,8 @@ class V8_EXPORT_PRIVATE VectorSlotPair { ...@@ -40,7 +40,8 @@ class V8_EXPORT_PRIVATE VectorSlotPair {
bool operator==(VectorSlotPair const&, VectorSlotPair const&); bool operator==(VectorSlotPair const&, VectorSlotPair const&);
bool operator!=(VectorSlotPair const&, VectorSlotPair const&); bool operator!=(VectorSlotPair const&, VectorSlotPair const&);
std::ostream& operator<<(std::ostream& os, VectorSlotPair const&); V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
VectorSlotPair const&);
size_t hash_value(VectorSlotPair const&); size_t hash_value(VectorSlotPair const&);
......
...@@ -131,6 +131,7 @@ v8_source_set("unittests_sources") { ...@@ -131,6 +131,7 @@ v8_source_set("unittests_sources") {
"compiler/node-unittest.cc", "compiler/node-unittest.cc",
"compiler/opcodes-unittest.cc", "compiler/opcodes-unittest.cc",
"compiler/persistent-unittest.cc", "compiler/persistent-unittest.cc",
"compiler/redundancy-elimination-unittest.cc",
"compiler/regalloc/live-range-unittest.cc", "compiler/regalloc/live-range-unittest.cc",
"compiler/regalloc/move-optimizer-unittest.cc", "compiler/regalloc/move-optimizer-unittest.cc",
"compiler/regalloc/register-allocator-unittest.cc", "compiler/regalloc/register-allocator-unittest.cc",
......
This diff is collapsed.
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