summaryrefslogtreecommitdiff
path: root/src/compiler/codegen/x86
diff options
context:
space:
mode:
author buzbee <buzbee@google.com> 2012-12-14 13:35:28 -0800
committer buzbee <buzbee@google.com> 2013-02-06 12:16:33 -0800
commit4ef3e45d7c6ec3c482a1a48f4df470811aa3cf0a (patch)
tree5d91ff23708048a2b453a5917dab82be1b545f91 /src/compiler/codegen/x86
parentf84f99fe3a944310fdfb6f17836079ac5c48c799 (diff)
Compiler constant handling rework
In preparation for de-optimization, reworked the constant handling mechanism. Also took advantage of knowledge of constant operands (particularly for long operations). Significant performance improvements for Mandelbrot (~60 seconds to ~34 seconds). Minor improvements in other benchmarks. The new constant handling breaks two of the existing optimization passes: "Skip Large Method" and "Load/Store Elimization." I don't intend to update the large method optimization because it will be superceeded by the upcoming interpreter/ fingerprinting mechanism. Leaving the code in place for now in order to compare compile-time improvements with fingerprinting/interpret. All related code will be deleted when that is complete. The load/store elimination pass needs some rework to handle uses of multiple-register loads and stores. It will be updated & restored in a future CL. Change-Id: Ia979abaf51b8ae81bbb0428031cbcea854625fac
Diffstat (limited to 'src/compiler/codegen/x86')
-rw-r--r--src/compiler/codegen/x86/codegen_x86.h14
-rw-r--r--src/compiler/codegen/x86/int_x86.cc21
-rw-r--r--src/compiler/codegen/x86/utility_x86.cc24
3 files changed, 52 insertions, 7 deletions
diff --git a/src/compiler/codegen/x86/codegen_x86.h b/src/compiler/codegen/x86/codegen_x86.h
index 141638cf1a..9cc17f130e 100644
--- a/src/compiler/codegen/x86/codegen_x86.h
+++ b/src/compiler/codegen/x86/codegen_x86.h
@@ -38,8 +38,7 @@ class X86Codegen : public Codegen {
int displacement, int r_dest, int r_dest_hi, OpSize size,
int s_reg);
virtual LIR* LoadConstantNoClobber(CompilationUnit* cu, int r_dest, int value);
- virtual LIR* LoadConstantValueWide(CompilationUnit* cu, int r_dest_lo, int r_dest_hi,
- int val_lo, int val_hi);
+ virtual LIR* LoadConstantWide(CompilationUnit* cu, int r_dest_lo, int r_dest_hi, int64_t value);
virtual LIR* StoreBaseDisp(CompilationUnit* cu, int rBase, int displacement, int r_src,
OpSize size);
virtual LIR* StoreBaseDispWide(CompilationUnit* cu, int rBase, int displacement, int r_src_lo,
@@ -90,12 +89,18 @@ class X86Codegen : public Codegen {
virtual bool IsUnconditionalBranch(LIR* lir);
// Required for target - Dalvik-level generators.
+ virtual bool GenArithImmOpLong(CompilationUnit* cu, Instruction::Code opcode, RegLocation rl_dest,
+ RegLocation rl_src1, RegLocation rl_src2);
virtual void GenArrayObjPut(CompilationUnit* cu, int opt_flags, RegLocation rl_array,
RegLocation rl_index, RegLocation rl_src, int scale);
virtual void GenArrayGet(CompilationUnit* cu, int opt_flags, OpSize size, RegLocation rl_array,
RegLocation rl_index, RegLocation rl_dest, int scale);
virtual void GenArrayPut(CompilationUnit* cu, int opt_flags, OpSize size, RegLocation rl_array,
RegLocation rl_index, RegLocation rl_src, int scale);
+ virtual bool GenShiftImmOpLong(CompilationUnit* cu, Instruction::Code opcode,
+ RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_shift);
+ virtual void GenMulLong(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src1,
+ RegLocation rl_src2);
virtual bool GenAddLong(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src1,
RegLocation rl_src2);
virtual bool GenAndLong(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src1,
@@ -188,7 +193,10 @@ class X86Codegen : public Codegen {
void SpillCoreRegs(CompilationUnit* cu);
void UnSpillCoreRegs(CompilationUnit* cu);
static const X86EncodingMap EncodingMap[kX86Last];
- bool InexpensiveConstant(int reg, int value);
+ bool InexpensiveConstantInt(int32_t value);
+ bool InexpensiveConstantFloat(int32_t value);
+ bool InexpensiveConstantLong(int64_t value);
+ bool InexpensiveConstantDouble(int64_t value);
};
} // namespace art
diff --git a/src/compiler/codegen/x86/int_x86.cc b/src/compiler/codegen/x86/int_x86.cc
index 0ae51e0e23..d4a34f7d37 100644
--- a/src/compiler/codegen/x86/int_x86.cc
+++ b/src/compiler/codegen/x86/int_x86.cc
@@ -322,6 +322,13 @@ LIR* X86Codegen::OpIT(CompilationUnit* cu, ConditionCode cond, const char* guide
LOG(FATAL) << "Unexpected use of OpIT in x86";
return NULL;
}
+
+void X86Codegen::GenMulLong(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src1,
+ RegLocation rl_src2)
+{
+ LOG(FATAL) << "Unexpected use of GenX86Long for x86";
+ return;
+}
bool X86Codegen::GenAddLong(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src1,
RegLocation rl_src2)
{
@@ -583,4 +590,18 @@ void X86Codegen::GenArrayObjPut(CompilationUnit* cu, int opt_flags, RegLocation
MarkGCCard(cu, r_value, r_array);
}
+bool X86Codegen::GenShiftImmOpLong(CompilationUnit* cu, Instruction::Code opcode, RegLocation rl_dest,
+ RegLocation rl_src1, RegLocation rl_shift)
+{
+ // Default implementation is just to ignore the constant case.
+ return GenShiftOpLong(cu, opcode, rl_dest, rl_src1, rl_shift);
+}
+
+bool X86Codegen::GenArithImmOpLong(CompilationUnit* cu, Instruction::Code opcode,
+ RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2)
+{
+ // Default - bail to non-const handler.
+ return GenArithOpLong(cu, opcode, rl_dest, rl_src1, rl_src2);
+}
+
} // namespace art
diff --git a/src/compiler/codegen/x86/utility_x86.cc b/src/compiler/codegen/x86/utility_x86.cc
index 4f9e28b444..4cc2c182cb 100644
--- a/src/compiler/codegen/x86/utility_x86.cc
+++ b/src/compiler/codegen/x86/utility_x86.cc
@@ -50,11 +50,26 @@ LIR* X86Codegen::OpFpRegCopy(CompilationUnit *cu, int r_dest, int r_src)
return res;
}
-bool X86Codegen::InexpensiveConstant(int reg, int value)
+bool X86Codegen::InexpensiveConstantInt(int32_t value)
{
return true;
}
+bool X86Codegen::InexpensiveConstantFloat(int32_t value)
+{
+ return false;
+}
+
+bool X86Codegen::InexpensiveConstantLong(int64_t value)
+{
+ return true;
+}
+
+bool X86Codegen::InexpensiveConstantDouble(int64_t value)
+{
+ return false; // TUNING
+}
+
/*
* Load a immediate using a shortcut if possible; otherwise
* grab from the per-translation literal pool. If target is
@@ -316,13 +331,14 @@ LIR* X86Codegen::OpMem(CompilationUnit* cu, OpKind op, int rBase, int disp)
return NewLIR2(cu, opcode, rBase, disp);
}
-LIR* X86Codegen::LoadConstantValueWide(CompilationUnit *cu, int r_dest_lo,
- int r_dest_hi, int val_lo, int val_hi)
+LIR* X86Codegen::LoadConstantWide(CompilationUnit *cu, int r_dest_lo, int r_dest_hi, int64_t value)
{
+ int32_t val_lo = Low32Bits(value);
+ int32_t val_hi = High32Bits(value);
LIR *res;
if (X86_FPREG(r_dest_lo)) {
DCHECK(X86_FPREG(r_dest_hi)); // ignore r_dest_hi
- if (val_lo == 0 && val_hi == 0) {
+ if (value == 0) {
return NewLIR2(cu, kX86XorpsRR, r_dest_lo, r_dest_lo);
} else {
if (val_lo == 0) {