Commit 1d963547 authored by danno's avatar danno Committed by Commit bot

[turbofan] Elide no-op adds in x64 index addressing modes

Before this patch, Loads generated in the CSA on x64 that have a zero offset
displacement will add a zero to the effective address rather than using an
addressing mode that folds away the zero.

This functionality already exists on ia32, but the port wasn't purely mechanical
so it hadn't been done on x64.

R=epertoso@chromium.org
LOG=N

Review-Url: https://codereview.chromium.org/2602893002
Cr-Commit-Position: refs/heads/master@{#41974}
parent d0838334
...@@ -82,6 +82,15 @@ class X64OperandGenerator final : public OperandGenerator { ...@@ -82,6 +82,15 @@ class X64OperandGenerator final : public OperandGenerator {
InstructionOperand inputs[], InstructionOperand inputs[],
size_t* input_count) { size_t* input_count) {
AddressingMode mode = kMode_MRI; AddressingMode mode = kMode_MRI;
if (base != nullptr && (index != nullptr || displacement != nullptr)) {
if (base->opcode() == IrOpcode::kInt32Constant &&
OpParameter<int32_t>(base) == 0) {
base = nullptr;
} else if (base->opcode() == IrOpcode::kInt64Constant &&
OpParameter<int64_t>(base) == 0) {
base = nullptr;
}
}
if (base != nullptr) { if (base != nullptr) {
inputs[(*input_count)++] = UseRegister(base); inputs[(*input_count)++] = UseRegister(base);
if (index != nullptr) { if (index != nullptr) {
...@@ -110,17 +119,22 @@ class X64OperandGenerator final : public OperandGenerator { ...@@ -110,17 +119,22 @@ class X64OperandGenerator final : public OperandGenerator {
} }
} }
} else { } else {
DCHECK_NOT_NULL(index);
DCHECK(scale_exponent >= 0 && scale_exponent <= 3); DCHECK(scale_exponent >= 0 && scale_exponent <= 3);
inputs[(*input_count)++] = UseRegister(index);
if (displacement != nullptr) { if (displacement != nullptr) {
inputs[(*input_count)++] = displacement_mode == kNegativeDisplacement if (index == nullptr) {
? UseNegatedImmediate(displacement) inputs[(*input_count)++] = UseRegister(displacement);
: UseImmediate(displacement); mode = kMode_MR;
static const AddressingMode kMnI_modes[] = {kMode_MRI, kMode_M2I, } else {
kMode_M4I, kMode_M8I}; inputs[(*input_count)++] = UseRegister(index);
mode = kMnI_modes[scale_exponent]; inputs[(*input_count)++] = displacement_mode == kNegativeDisplacement
? UseNegatedImmediate(displacement)
: UseImmediate(displacement);
static const AddressingMode kMnI_modes[] = {kMode_MRI, kMode_M2I,
kMode_M4I, kMode_M8I};
mode = kMnI_modes[scale_exponent];
}
} else { } else {
inputs[(*input_count)++] = UseRegister(index);
static const AddressingMode kMn_modes[] = {kMode_MR, kMode_MR1, static const AddressingMode kMn_modes[] = {kMode_MR, kMode_MR1,
kMode_M4, kMode_M8}; kMode_M4, kMode_M8};
mode = kMn_modes[scale_exponent]; mode = kMn_modes[scale_exponent];
......
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