From 4ef3e45d7c6ec3c482a1a48f4df470811aa3cf0a Mon Sep 17 00:00:00 2001 From: buzbee Date: Fri, 14 Dec 2012 13:35:28 -0800 Subject: 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 --- src/compiler/compiler_ir.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/compiler/compiler_ir.h') diff --git a/src/compiler/compiler_ir.h b/src/compiler/compiler_ir.h index aca32d5585..056c308c79 100644 --- a/src/compiler/compiler_ir.h +++ b/src/compiler/compiler_ir.h @@ -230,7 +230,8 @@ struct BasicBlock { bool catch_entry; bool explicit_throw; bool conditional_branch; - bool has_return; + bool has_return; // Contains a return. + bool dominates_return; // Is a member of return extended basic block uint16_t start_offset; uint16_t nesting_depth; BBType block_type; @@ -306,6 +307,7 @@ struct CompilationUnit { vreg_to_ssa_map(NULL), ssa_last_defs(NULL), is_constant_v(NULL), + must_flush_constant_v(NULL), constant_values(NULL), reg_location(NULL), promotion_map(NULL), @@ -418,6 +420,7 @@ struct CompilationUnit { int* vreg_to_ssa_map; // length == method->registers_size int* ssa_last_defs; // length == method->registers_size ArenaBitVector* is_constant_v; // length == num_ssa_reg + ArenaBitVector* must_flush_constant_v; // length == num_ssa_reg int* constant_values; // length == num_ssa_reg // Use counts of ssa names. @@ -579,6 +582,35 @@ static const CodePattern special_patterns[] = { {{Instruction::RETURN_WIDE}, kIdentity}, }; +static inline bool IsConst(const CompilationUnit* cu, int32_t s_reg) +{ + return (IsBitSet(cu->is_constant_v, s_reg)); +} + +static inline bool IsConst(const CompilationUnit* cu, RegLocation loc) +{ + return (IsConst(cu, loc.orig_sreg)); +} + +static inline int32_t ConstantValue(const CompilationUnit* cu, RegLocation loc) +{ + DCHECK(IsConst(cu, loc)); + return cu->constant_values[loc.orig_sreg]; +} + +static inline int64_t ConstantValueWide(const CompilationUnit* cu, RegLocation loc) +{ + DCHECK(IsConst(cu, loc)); + return (static_cast(cu->constant_values[loc.orig_sreg + 1]) << 32) | + Low32Bits(static_cast(cu->constant_values[loc.orig_sreg])); +} + +static inline bool MustFlushConstant(const CompilationUnit* cu, RegLocation loc) +{ + DCHECK(IsConst(cu, loc)); + return IsBitSet(cu->must_flush_constant_v, loc.orig_sreg); +} + } // namespace art #endif // ART_SRC_COMPILER_COMPILER_IR_H_ -- cgit v1.2.3-59-g8ed1b