diff options
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/constant_folding.cc | 27 | ||||
-rw-r--r-- | compiler/optimizing/intrinsics_mips.cc | 33 | ||||
-rw-r--r-- | compiler/optimizing/sharpening.cc | 10 |
3 files changed, 44 insertions, 26 deletions
diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc index 0614945ddc..5f39a49d68 100644 --- a/compiler/optimizing/constant_folding.cc +++ b/compiler/optimizing/constant_folding.cc @@ -47,6 +47,9 @@ class InstructionWithAbsorbingInputSimplifier : public HGraphVisitor { private: void VisitShift(HBinaryOperation* shift); + void VisitEqual(HEqual* instruction) OVERRIDE; + void VisitNotEqual(HNotEqual* instruction) OVERRIDE; + void VisitAbove(HAbove* instruction) OVERRIDE; void VisitAboveOrEqual(HAboveOrEqual* instruction) OVERRIDE; void VisitBelow(HBelow* instruction) OVERRIDE; @@ -140,6 +143,30 @@ void InstructionWithAbsorbingInputSimplifier::VisitShift(HBinaryOperation* instr } } +void InstructionWithAbsorbingInputSimplifier::VisitEqual(HEqual* instruction) { + if ((instruction->GetLeft()->IsNullConstant() && !instruction->GetRight()->CanBeNull()) || + (instruction->GetRight()->IsNullConstant() && !instruction->GetLeft()->CanBeNull())) { + // Replace code looking like + // EQUAL lhs, null + // where lhs cannot be null with + // CONSTANT false + instruction->ReplaceWith(GetGraph()->GetConstant(Primitive::kPrimBoolean, 0)); + instruction->GetBlock()->RemoveInstruction(instruction); + } +} + +void InstructionWithAbsorbingInputSimplifier::VisitNotEqual(HNotEqual* instruction) { + if ((instruction->GetLeft()->IsNullConstant() && !instruction->GetRight()->CanBeNull()) || + (instruction->GetRight()->IsNullConstant() && !instruction->GetLeft()->CanBeNull())) { + // Replace code looking like + // NOT_EQUAL lhs, null + // where lhs cannot be null with + // CONSTANT true + instruction->ReplaceWith(GetGraph()->GetConstant(Primitive::kPrimBoolean, 1)); + instruction->GetBlock()->RemoveInstruction(instruction); + } +} + void InstructionWithAbsorbingInputSimplifier::VisitAbove(HAbove* instruction) { if (instruction->GetLeft()->IsConstant() && instruction->GetLeft()->AsConstant()->IsArithmeticZero()) { diff --git a/compiler/optimizing/intrinsics_mips.cc b/compiler/optimizing/intrinsics_mips.cc index 862a93f9d6..e6e9c6552e 100644 --- a/compiler/optimizing/intrinsics_mips.cc +++ b/compiler/optimizing/intrinsics_mips.cc @@ -634,7 +634,7 @@ static void GenBitCount(LocationSummary* locations, // For 64-bit quantities, this algorithm gets executed twice, (once // for in_lo, and again for in_hi), but saves a few instructions // because the mask values only have to be loaded once. Using this - // algorithm the count for a 64-bit operand can be performed in 33 + // algorithm the count for a 64-bit operand can be performed in 29 // instructions compared to a loop-based algorithm which required 47 // instructions. @@ -687,37 +687,36 @@ static void GenBitCount(LocationSummary* locations, __ Srl(tmp_lo, tmp_lo, 2); __ And(tmp_lo, tmp_lo, AT); __ Addu(tmp_lo, out_lo, tmp_lo); - __ Srl(out_lo, tmp_lo, 4); - __ Addu(out_lo, out_lo, tmp_lo); __ And(out_hi, tmp_hi, AT); __ Srl(tmp_hi, tmp_hi, 2); __ And(tmp_hi, tmp_hi, AT); __ Addu(tmp_hi, out_hi, tmp_hi); - __ Srl(out_hi, tmp_hi, 4); - __ Addu(out_hi, out_hi, tmp_hi); + // Here we deviate from the original algorithm a bit. We've reached + // the stage where the bitfields holding the subtotals are large + // enough to hold the combined subtotals for both the low word, and + // the high word. This means that we can add the subtotals for the + // the high, and low words into a single word, and compute the final + // result for both the high, and low words using fewer instructions. __ LoadConst32(AT, 0x0F0F0F0F); - __ And(out_lo, out_lo, AT); - __ And(out_hi, out_hi, AT); + __ Addu(TMP, tmp_hi, tmp_lo); + + __ Srl(out, TMP, 4); + __ And(out, out, AT); + __ And(TMP, TMP, AT); + __ Addu(out, out, TMP); __ LoadConst32(AT, 0x01010101); if (isR6) { - __ MulR6(out_lo, out_lo, AT); - - __ MulR6(out_hi, out_hi, AT); + __ MulR6(out, out, AT); } else { - __ MulR2(out_lo, out_lo, AT); - - __ MulR2(out_hi, out_hi, AT); + __ MulR2(out, out, AT); } - __ Srl(out_lo, out_lo, 24); - __ Srl(out_hi, out_hi, 24); - - __ Addu(out, out_hi, out_lo); + __ Srl(out, out, 24); } } diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 40fff8af32..6effc306dc 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -295,15 +295,7 @@ void HSharpening::ProcessLoadString(HLoadString* load_string) { DCHECK(!runtime->UseJitCompilation()); mirror::String* string = class_linker->ResolveString(dex_file, string_index, dex_cache); CHECK(string != nullptr); - if (compiler_driver_->GetSupportBootImageFixup()) { - DCHECK(ContainsElement(compiler_driver_->GetDexFilesForOatFile(), &dex_file)); - desired_load_kind = codegen_->GetCompilerOptions().GetCompilePic() - ? HLoadString::LoadKind::kBootImageLinkTimePcRelative - : HLoadString::LoadKind::kBootImageLinkTimeAddress; - } else { - // MIPS64 or compiler_driver_test. Do not sharpen. - DCHECK_EQ(desired_load_kind, HLoadString::LoadKind::kDexCacheViaMethod); - } + // TODO: In follow up CL, add PcRelative and Address back in. } else if (runtime->UseJitCompilation()) { // TODO: Make sure we don't set the "compile PIC" flag for JIT as that's bogus. // DCHECK(!codegen_->GetCompilerOptions().GetCompilePic()); |