Commit 5c4c4ed5 authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

[turbofan,x64] Enable fancy addressing modes for poisoned loads.

This is based on https://chromium-review.googlesource.com/c/v8/v8/+/940174.
It is fine to use the more complex addressing modes here because our
poisoning does not poison indexes anymore (it poisons value instead).

Bug: chromium:839789
Change-Id: I818a060f835f7dea842cb855d077e871a95b2c01
Reviewed-on: https://chromium-review.googlesource.com/1065773
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53303}
parent 97a1db79
......@@ -491,14 +491,14 @@ struct BaseWithIndexAndDisplacementMatcher {
bool power_of_two_plus_one = false;
DisplacementMode displacement_mode = kPositiveDisplacement;
int scale = 0;
if (m.HasIndexInput() && left->OwnedByAddressingOperand()) {
if (m.HasIndexInput() && OwnedByAddressingOperand(left)) {
index = m.IndexInput();
scale = m.scale();
scale_expression = left;
power_of_two_plus_one = m.power_of_two_plus_one();
bool match_found = false;
if (right->opcode() == AddMatcher::kSubOpcode &&
right->OwnedByAddressingOperand()) {
OwnedByAddressingOperand(right)) {
AddMatcher right_matcher(right);
if (right_matcher.right().HasValue()) {
// (S + (B - D))
......@@ -510,7 +510,7 @@ struct BaseWithIndexAndDisplacementMatcher {
}
if (!match_found) {
if (right->opcode() == AddMatcher::kAddOpcode &&
right->OwnedByAddressingOperand()) {
OwnedByAddressingOperand(right)) {
AddMatcher right_matcher(right);
if (right_matcher.right().HasValue()) {
// (S + (B + D))
......@@ -531,7 +531,7 @@ struct BaseWithIndexAndDisplacementMatcher {
} else {
bool match_found = false;
if (left->opcode() == AddMatcher::kSubOpcode &&
left->OwnedByAddressingOperand()) {
OwnedByAddressingOperand(left)) {
AddMatcher left_matcher(left);
Node* left_left = left_matcher.left().node();
Node* left_right = left_matcher.right().node();
......@@ -557,7 +557,7 @@ struct BaseWithIndexAndDisplacementMatcher {
}
if (!match_found) {
if (left->opcode() == AddMatcher::kAddOpcode &&
left->OwnedByAddressingOperand()) {
OwnedByAddressingOperand(left)) {
AddMatcher left_matcher(left);
Node* left_left = left_matcher.left().node();
Node* left_right = left_matcher.right().node();
......@@ -667,6 +667,29 @@ struct BaseWithIndexAndDisplacementMatcher {
scale_ = scale;
matches_ = true;
}
static bool OwnedByAddressingOperand(Node* node) {
for (auto use : node->use_edges()) {
Node* from = use.from();
switch (from->opcode()) {
case IrOpcode::kLoad:
case IrOpcode::kPoisonedLoad:
case IrOpcode::kInt32Add:
case IrOpcode::kInt64Add:
// Skip addressing uses.
break;
case IrOpcode::kStore:
// If the stored value is this node, it is not an addressing use.
if (from->InputAt(2) == node) return false;
// Otherwise it is used as an address and skipped.
break;
default:
// Non-addressing use found.
return false;
}
}
return true;
}
};
typedef BaseWithIndexAndDisplacementMatcher<Int32AddMatcher>
......
......@@ -296,20 +296,6 @@ bool Node::OwnedBy(Node const* owner1, Node const* owner2) const {
return mask == 3;
}
bool Node::OwnedByAddressingOperand() const {
for (Use* use = first_use_; use; use = use->next) {
Node* from = use->from();
if (from->opcode() != IrOpcode::kLoad &&
// If {from} is store, make sure it does not use {this} as value
(from->opcode() != IrOpcode::kStore || from->InputAt(2) == this) &&
from->opcode() != IrOpcode::kInt32Add &&
from->opcode() != IrOpcode::kInt64Add) {
return false;
}
}
return true;
}
void Node::Print() const {
OFStream os(stdout);
os << *this << std::endl;
......
......@@ -159,9 +159,6 @@ class V8_EXPORT_PRIVATE Node final {
// Returns true if {owner1} and {owner2} are the only users of {this} node.
bool OwnedBy(Node const* owner1, Node const* owner2) const;
// Returns true if addressing related operands (such as load, store, lea)
// are the only users of {this} node.
bool OwnedByAddressingOperand() const;
void Print() const;
private:
......
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