summaryrefslogtreecommitdiff
path: root/src/compiler/ralloc.cc
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/ralloc.cc
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/ralloc.cc')
-rw-r--r--src/compiler/ralloc.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/compiler/ralloc.cc b/src/compiler/ralloc.cc
index 2038e192bf..35142008d2 100644
--- a/src/compiler/ralloc.cc
+++ b/src/compiler/ralloc.cc
@@ -479,6 +479,39 @@ void SimpleRegAlloc(CompilationUnit* cu)
}
}
+ /*
+ * Now that everything is typed and constants propagated, identify those constants
+ * that can be cheaply materialized and don't need to be flushed to a home location.
+ * The default is to not flush, and some have already been marked as must flush.
+ */
+ for (i=0; i < cu->num_ssa_regs; i++) {
+ if (IsBitSet(cu->is_constant_v, i)) {
+ bool flush = false;
+ RegLocation loc = cu->reg_location[i];
+ if (loc.wide) {
+ int64_t value = ConstantValueWide(cu, loc);
+ if (loc.fp) {
+ flush = !cu->cg->InexpensiveConstantDouble(value);
+ } else {
+ flush = !cu->cg->InexpensiveConstantLong(value);
+ }
+ } else {
+ int32_t value = ConstantValue(cu, loc);
+ if (loc.fp) {
+ flush = !cu->cg->InexpensiveConstantFloat(value);
+ } else {
+ flush = !cu->cg->InexpensiveConstantInt(value);
+ }
+ }
+ if (flush) {
+ SetBit(cu, cu->must_flush_constant_v, i);
+ }
+ if (loc.wide) {
+ i++; // Skip the high word
+ }
+ }
+ }
+
cu->core_spill_mask = 0;
cu->fp_spill_mask = 0;
cu->num_core_spills = 0;