Commit 103b3595 authored by Hao Xu's avatar Hao Xu Committed by V8 LUCI CQ

[compiler] Avoid using register to save scaled index in addressing mode

Drive-by fix: Fix some typos in comments.

Bug: v8:12319
Change-Id: Ieb4f9ab26bd4e07125ff17df9c048681733cf758
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3222263Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Hao A Xu <hao.a.xu@intel.com>
Cr-Commit-Position: refs/heads/main@{#77570}
parent 770746bc
...@@ -383,8 +383,8 @@ namespace compiler { ...@@ -383,8 +383,8 @@ namespace compiler {
V(MR8) /* [%r1 + %r2*8 ] */ \ V(MR8) /* [%r1 + %r2*8 ] */ \
V(MR1I) /* [%r1 + %r2*1 + K] */ \ V(MR1I) /* [%r1 + %r2*1 + K] */ \
V(MR2I) /* [%r1 + %r2*2 + K] */ \ V(MR2I) /* [%r1 + %r2*2 + K] */ \
V(MR4I) /* [%r1 + %r2*3 + K] */ \ V(MR4I) /* [%r1 + %r2*4 + K] */ \
V(MR8I) /* [%r1 + %r2*4 + K] */ \ V(MR8I) /* [%r1 + %r2*8 + K] */ \
V(M1) /* [ %r2*1 ] */ \ V(M1) /* [ %r2*1 ] */ \
V(M2) /* [ %r2*2 ] */ \ V(M2) /* [ %r2*2 ] */ \
V(M4) /* [ %r2*4 ] */ \ V(M4) /* [ %r2*4 ] */ \
......
...@@ -423,8 +423,8 @@ namespace compiler { ...@@ -423,8 +423,8 @@ namespace compiler {
V(MR8) /* [%r1 + %r2*8 ] */ \ V(MR8) /* [%r1 + %r2*8 ] */ \
V(MR1I) /* [%r1 + %r2*1 + K] */ \ V(MR1I) /* [%r1 + %r2*1 + K] */ \
V(MR2I) /* [%r1 + %r2*2 + K] */ \ V(MR2I) /* [%r1 + %r2*2 + K] */ \
V(MR4I) /* [%r1 + %r2*3 + K] */ \ V(MR4I) /* [%r1 + %r2*4 + K] */ \
V(MR8I) /* [%r1 + %r2*4 + K] */ \ V(MR8I) /* [%r1 + %r2*8 + K] */ \
V(M1) /* [ %r2*1 ] */ \ V(M1) /* [ %r2*1 ] */ \
V(M2) /* [ %r2*2 ] */ \ V(M2) /* [ %r2*2 ] */ \
V(M4) /* [ %r2*4 ] */ \ V(M4) /* [ %r2*4 ] */ \
......
...@@ -606,7 +606,8 @@ struct BaseWithIndexAndDisplacementMatcher { ...@@ -606,7 +606,8 @@ struct BaseWithIndexAndDisplacementMatcher {
Node* left_left = left_matcher.left().node(); Node* left_left = left_matcher.left().node();
Node* left_right = left_matcher.right().node(); Node* left_right = left_matcher.right().node();
if (left_matcher.right().HasResolvedValue()) { if (left_matcher.right().HasResolvedValue()) {
if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { if (left_matcher.HasIndexInput() &&
OwnedByAddressingOperand(left_left)) {
// ((S - D) + B) // ((S - D) + B)
index = left_matcher.IndexInput(); index = left_matcher.IndexInput();
scale = left_matcher.scale(); scale = left_matcher.scale();
...@@ -631,7 +632,8 @@ struct BaseWithIndexAndDisplacementMatcher { ...@@ -631,7 +632,8 @@ struct BaseWithIndexAndDisplacementMatcher {
AddMatcher left_matcher(left); AddMatcher left_matcher(left);
Node* left_left = left_matcher.left().node(); Node* left_left = left_matcher.left().node();
Node* left_right = left_matcher.right().node(); Node* left_right = left_matcher.right().node();
if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { if (left_matcher.HasIndexInput() &&
OwnedByAddressingOperand(left_left)) {
if (left_matcher.right().HasResolvedValue()) { if (left_matcher.right().HasResolvedValue()) {
// ((S + D) + B) // ((S + D) + B)
index = left_matcher.IndexInput(); index = left_matcher.IndexInput();
...@@ -738,6 +740,8 @@ struct BaseWithIndexAndDisplacementMatcher { ...@@ -738,6 +740,8 @@ struct BaseWithIndexAndDisplacementMatcher {
matches_ = true; matches_ = true;
} }
// Warning: When {node} is used by a Add/Sub instruction, this function does
// not guarantee the Add/Sub will be part of a addressing operand.
static bool OwnedByAddressingOperand(Node* node) { static bool OwnedByAddressingOperand(Node* node) {
for (auto use : node->use_edges()) { for (auto use : node->use_edges()) {
Node* from = use.from(); Node* from = use.from();
...@@ -749,6 +753,16 @@ struct BaseWithIndexAndDisplacementMatcher { ...@@ -749,6 +753,16 @@ struct BaseWithIndexAndDisplacementMatcher {
case IrOpcode::kInt64Add: case IrOpcode::kInt64Add:
// Skip addressing uses. // Skip addressing uses.
break; break;
case IrOpcode::kInt32Sub:
// If the subtrahend is not a constant, it is not an addressing use.
if (from->InputAt(1)->opcode() != IrOpcode::kInt32Constant)
return false;
break;
case IrOpcode::kInt64Sub:
// If the subtrahend is not a constant, it is not an addressing use.
if (from->InputAt(1)->opcode() != IrOpcode::kInt64Constant)
return false;
break;
case IrOpcode::kStore: case IrOpcode::kStore:
case IrOpcode::kProtectedStore: case IrOpcode::kProtectedStore:
// If the stored value is this node, it is not an addressing use. // If the stored value is this node, it is not an addressing use.
......
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