Commit d40195e4 authored by bradnelson's avatar bradnelson Committed by Commit bot

Revert "[ia32] Optimize index calculation for certain checked load/stores."

This reverts commit 5c1babcc.

This seems to regress a range of benchmarks on ia32:
  Emscripten for Fannkuch, Zlib, MemOps, Life, Bullet
  AreWeFastYet for BulletLoadTime, Fasta, Fannkuch
  JetStream for towers.c, quicksort.c, gcc-loops.cpp, bigfib.cpp

BUG=673861
R=jarin@chromium.org,shiyu.zhang@intel.com

Review-Url: https://codereview.chromium.org/2573983003
Cr-Commit-Position: refs/heads/master@{#41696}
parent 21255208
...@@ -185,9 +185,9 @@ bool HasImmediateInput(Instruction* instr, size_t index) { ...@@ -185,9 +185,9 @@ bool HasImmediateInput(Instruction* instr, size_t index) {
return instr->InputAt(index)->IsImmediate(); return instr->InputAt(index)->IsImmediate();
} }
class OutOfLineLoadZero final : public OutOfLineCode { class OutOfLineLoadInteger final : public OutOfLineCode {
public: public:
OutOfLineLoadZero(CodeGenerator* gen, Register result) OutOfLineLoadInteger(CodeGenerator* gen, Register result)
: OutOfLineCode(gen), result_(result) {} : OutOfLineCode(gen), result_(result) {}
void Generate() final { __ xor_(result_, result_); } void Generate() final { __ xor_(result_, result_); }
...@@ -285,391 +285,66 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -285,391 +285,66 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
} // namespace } // namespace
#define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, OutOfLineLoadNaN, \ #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, OutOfLineLoadNaN) \
SingleOrDouble) \
do { \ do { \
auto result = i.OutputDoubleRegister(); \ auto result = i.OutputDoubleRegister(); \
auto index1 = i.InputRegister(1); \ auto offset = i.InputRegister(0); \
auto index2 = i.InputInt32(2); \ if (instr->InputAt(1)->IsRegister()) { \
OutOfLineCode* ool; \ __ cmp(offset, i.InputRegister(1)); \
if (index2 == 0) { \
if (instr->InputAt(3)->IsRegister()) { \
__ cmp(index1, i.InputRegister(3)); \
} else { \
__ cmp(index1, i.InputImmediate(3)); \
} \
ool = new (zone()) OutOfLineLoadNaN(this, result); \
} else { \
auto length = i.InputInt32(3); \
RelocInfo::Mode rmode = i.ToConstant(instr->InputAt(3)).rmode(); \
DCHECK_LE(index2, length); \
__ cmp(index1, \
Immediate(reinterpret_cast<Address>(length - index2), rmode)); \
class OutOfLineLoadFloat final : public OutOfLineCode { \
public: \
OutOfLineLoadFloat(CodeGenerator* gen, XMMRegister result, \
Register buffer, Register index1, int32_t index2, \
int32_t length, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
result_(result), \
buffer_reg_(buffer), \
buffer_int_(0), \
index1_(index1), \
index2_(index2), \
length_(length), \
rmode_(rmode) {} \
\
OutOfLineLoadFloat(CodeGenerator* gen, XMMRegister result, \
int32_t buffer, Register index1, int32_t index2, \
int32_t length, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
result_(result), \
buffer_reg_({-1}), \
buffer_int_(buffer), \
index1_(index1), \
index2_(index2), \
length_(length), \
rmode_(rmode) {} \
\
void Generate() final { \
Label oob; \
__ push(index1_); \
__ lea(index1_, Operand(index1_, index2_)); \
__ cmp(index1_, \
Immediate(reinterpret_cast<Address>(length_), rmode_)); \
__ j(above_equal, &oob, Label::kNear); \
if (buffer_reg_.is_valid()) { \
__ asm_instr(result_, Operand(buffer_reg_, index1_, times_1, 0)); \
} else { \
__ asm_instr(result_, Operand(index1_, buffer_int_)); \
} \
__ pop(index1_); \
__ jmp(exit()); \
__ bind(&oob); \
__ pop(index1_); \
__ xorp##SingleOrDouble(result_, result_); \
__ divs##SingleOrDouble(result_, result_); \
} \
\
private: \
XMMRegister const result_; \
Register const buffer_reg_; \
int32_t const buffer_int_; \
Register const index1_; \
int32_t const index2_; \
int32_t const length_; \
RelocInfo::Mode rmode_; \
}; \
if (instr->InputAt(0)->IsRegister()) { \
ool = new (zone()) OutOfLineLoadFloat( \
this, result, i.InputRegister(0), index1, index2, length, rmode); \
} else { \ } else { \
ool = new (zone()) OutOfLineLoadFloat(this, result, i.InputInt32(0), \ __ cmp(offset, i.InputImmediate(1)); \
index1, index2, length, rmode); \
} \
} \ } \
OutOfLineCode* ool = new (zone()) OutOfLineLoadNaN(this, result); \
__ j(above_equal, ool->entry()); \ __ j(above_equal, ool->entry()); \
if (instr->InputAt(0)->IsRegister()) { \ __ asm_instr(result, i.MemoryOperand(2)); \
__ asm_instr(result, \
Operand(i.InputRegister(0), index1, times_1, index2)); \
} else { \
__ asm_instr(result, Operand(index1, (i.InputInt32(0) + index2))); \
} \
__ bind(ool->exit()); \ __ bind(ool->exit()); \
} while (false) } while (false)
#define ASSEMBLE_CHECKED_LOAD_INTEGER(asm_instr) \ #define ASSEMBLE_CHECKED_LOAD_INTEGER(asm_instr) \
do { \ do { \
auto result = i.OutputRegister(); \ auto result = i.OutputRegister(); \
auto index1 = i.InputRegister(1); \ auto offset = i.InputRegister(0); \
auto index2 = i.InputInt32(2); \ if (instr->InputAt(1)->IsRegister()) { \
OutOfLineCode* ool; \ __ cmp(offset, i.InputRegister(1)); \
if (index2 == 0) { \
if (instr->InputAt(3)->IsRegister()) { \
__ cmp(index1, i.InputRegister(3)); \
} else { \
__ cmp(index1, i.InputImmediate(3)); \
} \
ool = new (zone()) OutOfLineLoadZero(this, result); \
} else { \
auto length = i.InputInt32(3); \
RelocInfo::Mode rmode = i.ToConstant(instr->InputAt(3)).rmode(); \
DCHECK_LE(index2, length); \
__ cmp(index1, \
Immediate(reinterpret_cast<Address>(length - index2), rmode)); \
class OutOfLineLoadInteger final : public OutOfLineCode { \
public: \
OutOfLineLoadInteger(CodeGenerator* gen, Register result, \
Register buffer, Register index1, int32_t index2, \
int32_t length, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
result_(result), \
buffer_reg_(buffer), \
buffer_int_(0), \
index1_(index1), \
index2_(index2), \
length_(length), \
rmode_(rmode) {} \
\
OutOfLineLoadInteger(CodeGenerator* gen, Register result, \
int32_t buffer, Register index1, int32_t index2, \
int32_t length, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
result_(result), \
buffer_reg_({-1}), \
buffer_int_(buffer), \
index1_(index1), \
index2_(index2), \
length_(length), \
rmode_(rmode) {} \
\
void Generate() final { \
Label oob; \
bool need_cache = !result_.is(index1_); \
if (need_cache) __ push(index1_); \
__ lea(index1_, Operand(index1_, index2_)); \
__ cmp(index1_, \
Immediate(reinterpret_cast<Address>(length_), rmode_)); \
__ j(above_equal, &oob, Label::kNear); \
if (buffer_reg_.is_valid()) { \
__ asm_instr(result_, Operand(buffer_reg_, index1_, times_1, 0)); \
} else { \
__ asm_instr(result_, Operand(index1_, buffer_int_)); \
} \
if (need_cache) __ pop(index1_); \
__ jmp(exit()); \
__ bind(&oob); \
if (need_cache) __ pop(index1_); \
__ xor_(result_, result_); \
} \
\
private: \
Register const result_; \
Register const buffer_reg_; \
int32_t const buffer_int_; \
Register const index1_; \
int32_t const index2_; \
int32_t const length_; \
RelocInfo::Mode const rmode_; \
}; \
if (instr->InputAt(0)->IsRegister()) { \
ool = new (zone()) OutOfLineLoadInteger( \
this, result, i.InputRegister(0), index1, index2, length, rmode); \
} else { \ } else { \
ool = new (zone()) OutOfLineLoadInteger( \ __ cmp(offset, i.InputImmediate(1)); \
this, result, i.InputInt32(0), index1, index2, length, rmode); \
} \
} \ } \
OutOfLineCode* ool = new (zone()) OutOfLineLoadInteger(this, result); \
__ j(above_equal, ool->entry()); \ __ j(above_equal, ool->entry()); \
if (instr->InputAt(0)->IsRegister()) { \ __ asm_instr(result, i.MemoryOperand(2)); \
__ asm_instr(result, \
Operand(i.InputRegister(0), index1, times_1, index2)); \
} else { \
__ asm_instr(result, Operand(index1, (i.InputInt32(0) + index2))); \
} \
__ bind(ool->exit()); \ __ bind(ool->exit()); \
} while (false) } while (false)
#define ASSEMBLE_CHECKED_STORE_FLOAT(asm_instr) \ #define ASSEMBLE_CHECKED_STORE_FLOAT(asm_instr) \
do { \ do { \
auto index1 = i.InputRegister(1); \ auto offset = i.InputRegister(0); \
auto index2 = i.InputInt32(2); \ if (instr->InputAt(1)->IsRegister()) { \
auto value = i.InputDoubleRegister(4); \ __ cmp(offset, i.InputRegister(1)); \
if (index2 == 0) { \
if (instr->InputAt(3)->IsRegister()) { \
__ cmp(index1, i.InputRegister(3)); \
} else { \ } else { \
__ cmp(index1, i.InputImmediate(3)); \ __ cmp(offset, i.InputImmediate(1)); \
} \ } \
Label done; \ Label done; \
__ j(above_equal, &done, Label::kNear); \ __ j(above_equal, &done, Label::kNear); \
if (instr->InputAt(0)->IsRegister()) { \ __ asm_instr(i.MemoryOperand(3), i.InputDoubleRegister(2)); \
__ asm_instr(Operand(i.InputRegister(0), index1, times_1, index2), \
value); \
} else { \
__ asm_instr(Operand(index1, (i.InputInt32(0) + index2)), value); \
} \
__ bind(&done); \ __ bind(&done); \
} else { \
auto length = i.InputInt32(3); \
RelocInfo::Mode rmode = i.ToConstant(instr->InputAt(3)).rmode(); \
DCHECK_LE(index2, length); \
__ cmp(index1, \
Immediate(reinterpret_cast<Address>(length - index2), rmode)); \
class OutOfLineStoreFloat final : public OutOfLineCode { \
public: \
OutOfLineStoreFloat(CodeGenerator* gen, Register buffer, \
Register index1, int32_t index2, int32_t length, \
XMMRegister value, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
buffer_reg_(buffer), \
buffer_int_(0), \
index1_(index1), \
index2_(index2), \
length_(length), \
value_(value), \
rmode_(rmode) {} \
\
OutOfLineStoreFloat(CodeGenerator* gen, int32_t buffer, \
Register index1, int32_t index2, int32_t length, \
XMMRegister value, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
buffer_reg_({-1}), \
buffer_int_(buffer), \
index1_(index1), \
index2_(index2), \
length_(length), \
value_(value), \
rmode_(rmode) {} \
\
void Generate() final { \
Label oob; \
__ push(index1_); \
__ lea(index1_, Operand(index1_, index2_)); \
__ cmp(index1_, \
Immediate(reinterpret_cast<Address>(length_), rmode_)); \
__ j(above_equal, &oob, Label::kNear); \
if (buffer_reg_.is_valid()) { \
__ asm_instr(Operand(buffer_reg_, index1_, times_1, 0), value_); \
} else { \
__ asm_instr(Operand(index1_, buffer_int_), value_); \
} \
__ bind(&oob); \
__ pop(index1_); \
} \
\
private: \
Register const buffer_reg_; \
int32_t const buffer_int_; \
Register const index1_; \
int32_t const index2_; \
int32_t const length_; \
XMMRegister const value_; \
RelocInfo::Mode rmode_; \
}; \
OutOfLineCode* ool; \
if (instr->InputAt(0)->IsRegister()) { \
ool = new (zone()) OutOfLineStoreFloat( \
this, i.InputRegister(0), index1, index2, length, value, rmode); \
} else { \
ool = new (zone()) OutOfLineStoreFloat(this, i.InputInt32(0), index1, \
index2, length, value, rmode); \
} \
__ j(above_equal, ool->entry()); \
if (instr->InputAt(0)->IsRegister()) { \
__ asm_instr(Operand(i.InputRegister(0), index1, times_1, index2), \
value); \
} else { \
__ asm_instr(Operand(index1, (i.InputInt32(0) + index2)), value); \
} \
__ bind(ool->exit()); \
} \
} while (false) } while (false)
#define ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Value) \ #define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \
do { \ do { \
auto index1 = i.InputRegister(1); \ auto offset = i.InputRegister(0); \
auto index2 = i.InputInt32(2); \ if (instr->InputAt(1)->IsRegister()) { \
if (index2 == 0) { \ __ cmp(offset, i.InputRegister(1)); \
if (instr->InputAt(3)->IsRegister()) { \
__ cmp(index1, i.InputRegister(3)); \
} else { \ } else { \
__ cmp(index1, i.InputImmediate(3)); \ __ cmp(offset, i.InputImmediate(1)); \
} \ } \
Label done; \ Label done; \
__ j(above_equal, &done, Label::kNear); \ __ j(above_equal, &done, Label::kNear); \
if (instr->InputAt(0)->IsRegister()) { \ if (instr->InputAt(2)->IsRegister()) { \
__ asm_instr(Operand(i.InputRegister(0), index1, times_1, index2), \ __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \
value); \
} else { \ } else { \
__ asm_instr(Operand(index1, (i.InputInt32(0) + index2)), value); \ __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \
} \ } \
__ bind(&done); \ __ bind(&done); \
} else { \
auto length = i.InputInt32(3); \
RelocInfo::Mode rmode = i.ToConstant(instr->InputAt(3)).rmode(); \
DCHECK_LE(index2, length); \
__ cmp(index1, \
Immediate(reinterpret_cast<Address>(length - index2), rmode)); \
class OutOfLineStoreInteger final : public OutOfLineCode { \
public: \
OutOfLineStoreInteger(CodeGenerator* gen, Register buffer, \
Register index1, int32_t index2, int32_t length, \
Value value, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
buffer_reg_(buffer), \
buffer_int_(0), \
index1_(index1), \
index2_(index2), \
length_(length), \
value_(value), \
rmode_(rmode) {} \
\
OutOfLineStoreInteger(CodeGenerator* gen, int32_t buffer, \
Register index1, int32_t index2, int32_t length, \
Value value, RelocInfo::Mode rmode) \
: OutOfLineCode(gen), \
buffer_reg_({-1}), \
buffer_int_(buffer), \
index1_(index1), \
index2_(index2), \
length_(length), \
value_(value), \
rmode_(rmode) {} \
\
void Generate() final { \
Label oob; \
__ push(index1_); \
__ lea(index1_, Operand(index1_, index2_)); \
__ cmp(index1_, \
Immediate(reinterpret_cast<Address>(length_), rmode_)); \
__ j(above_equal, &oob, Label::kNear); \
if (buffer_reg_.is_valid()) { \
__ asm_instr(Operand(buffer_reg_, index1_, times_1, 0), value_); \
} else { \
__ asm_instr(Operand(index1_, buffer_int_), value_); \
} \
__ bind(&oob); \
__ pop(index1_); \
} \
\
private: \
Register const buffer_reg_; \
int32_t const buffer_int_; \
Register const index1_; \
int32_t const index2_; \
int32_t const length_; \
Value const value_; \
RelocInfo::Mode rmode_; \
}; \
OutOfLineCode* ool; \
if (instr->InputAt(0)->IsRegister()) { \
ool = new (zone()) OutOfLineStoreInteger( \
this, i.InputRegister(0), index1, index2, length, value, rmode); \
} else { \
ool = new (zone()) OutOfLineStoreInteger( \
this, i.InputInt32(0), index1, index2, length, value, rmode); \
} \
__ j(above_equal, ool->entry()); \
if (instr->InputAt(0)->IsRegister()) { \
__ asm_instr(Operand(i.InputRegister(0), index1, times_1, index2), \
value); \
} else { \
__ asm_instr(Operand(index1, (i.InputInt32(0) + index2)), value); \
} \
__ bind(ool->exit()); \
} \
} while (false)
#define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \
do { \
if (instr->InputAt(4)->IsRegister()) { \
Register value = i.InputRegister(4); \
ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Register); \
} else { \
Immediate value = i.InputImmediate(4); \
ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Immediate); \
} \
} while (false) } while (false)
#define ASSEMBLE_COMPARE(asm_instr) \ #define ASSEMBLE_COMPARE(asm_instr) \
...@@ -1889,10 +1564,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1889,10 +1564,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
ASSEMBLE_CHECKED_LOAD_INTEGER(mov); ASSEMBLE_CHECKED_LOAD_INTEGER(mov);
break; break;
case kCheckedLoadFloat32: case kCheckedLoadFloat32:
ASSEMBLE_CHECKED_LOAD_FLOAT(movss, OutOfLineLoadFloat32NaN, s); ASSEMBLE_CHECKED_LOAD_FLOAT(movss, OutOfLineLoadFloat32NaN);
break; break;
case kCheckedLoadFloat64: case kCheckedLoadFloat64:
ASSEMBLE_CHECKED_LOAD_FLOAT(movsd, OutOfLineLoadFloat64NaN, d); ASSEMBLE_CHECKED_LOAD_FLOAT(movsd, OutOfLineLoadFloat64NaN);
break; break;
case kCheckedStoreWord8: case kCheckedStoreWord8:
ASSEMBLE_CHECKED_STORE_INTEGER(mov_b); ASSEMBLE_CHECKED_STORE_INTEGER(mov_b);
......
...@@ -395,25 +395,18 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { ...@@ -395,25 +395,18 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
UNREACHABLE(); UNREACHABLE();
return; return;
} }
Int32Matcher mbuffer(buffer); InstructionOperand offset_operand = g.UseRegister(offset);
InstructionOperand buffer_operand =
mbuffer.HasValue() ? g.UseImmediate(buffer) : g.UseRegister(buffer);
if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
Int32Matcher mlength(length);
Int32BinopMatcher moffset(offset);
if (mlength.HasValue() && moffset.right().HasValue() &&
moffset.right().Value() > 0 &&
mlength.Value() >= moffset.right().Value()) {
Emit(opcode, g.DefineAsRegister(node), buffer_operand,
g.UseRegister(moffset.left().node()),
g.UseImmediate(moffset.right().node()), g.UseImmediate(length));
return;
}
}
InstructionOperand length_operand = InstructionOperand length_operand =
g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length); g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
Emit(opcode, g.DefineAsRegister(node), buffer_operand, g.UseRegister(offset), if (g.CanBeImmediate(buffer)) {
g.TempImmediate(0), length_operand); Emit(opcode | AddressingModeField::encode(kMode_MRI),
g.DefineAsRegister(node), offset_operand, length_operand,
offset_operand, g.UseImmediate(buffer));
} else {
Emit(opcode | AddressingModeField::encode(kMode_MR1),
g.DefineAsRegister(node), offset_operand, length_operand,
g.UseRegister(buffer), offset_operand);
}
} }
...@@ -457,26 +450,18 @@ void InstructionSelector::VisitCheckedStore(Node* node) { ...@@ -457,26 +450,18 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
rep == MachineRepresentation::kBit) rep == MachineRepresentation::kBit)
? g.UseByteRegister(value) ? g.UseByteRegister(value)
: g.UseRegister(value)); : g.UseRegister(value));
Int32Matcher mbuffer(buffer); InstructionOperand offset_operand = g.UseRegister(offset);
InstructionOperand buffer_operand =
mbuffer.HasValue() ? g.UseImmediate(buffer) : g.UseRegister(buffer);
if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
Int32Matcher mlength(length);
Int32BinopMatcher moffset(offset);
if (mlength.HasValue() && moffset.right().HasValue() &&
moffset.right().Value() > 0 &&
mlength.Value() >= moffset.right().Value()) {
Emit(opcode, g.NoOutput(), buffer_operand,
g.UseRegister(moffset.left().node()),
g.UseImmediate(moffset.right().node()), g.UseImmediate(length),
value_operand);
return;
}
}
InstructionOperand length_operand = InstructionOperand length_operand =
g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length); g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
Emit(opcode, g.NoOutput(), buffer_operand, g.UseRegister(offset), if (g.CanBeImmediate(buffer)) {
g.TempImmediate(0), length_operand, value_operand); Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(),
offset_operand, length_operand, value_operand, offset_operand,
g.UseImmediate(buffer));
} else {
Emit(opcode | AddressingModeField::encode(kMode_MR1), g.NoOutput(),
offset_operand, length_operand, value_operand, g.UseRegister(buffer),
offset_operand);
}
} }
namespace { namespace {
......
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