diff options
| author | Mingyao Yang <mingyao@google.com> | 2017-11-21 14:44:54 -0800 |
|---|---|---|
| committer | Mingyao Yang <mingyao@google.com> | 2017-11-22 10:46:57 -0800 |
| commit | cebb5e709af5ed5b475a56743f984967d991e7b9 (patch) | |
| tree | db2b6c243606979c905ec10a5cced999eba0f209 /compiler/optimizing/instruction_simplifier.cc | |
| parent | 8cceb1faf894c26b89ceacd3d60599fe0b4b93b7 (diff) | |
| download | art-cebb5e709af5ed5b475a56743f984967d991e7b9.tar.gz art-cebb5e709af5ed5b475a56743f984967d991e7b9.tar.bz2 art-cebb5e709af5ed5b475a56743f984967d991e7b9.zip | |
type conversion elimination for constant input
type conversion on constant input can be eliminated if the constant
value falls in the result type's range.
Test: run-test on host, 711-checker-type-conversion
Change-Id: I372139d681aa06fa6e760d7814c86ac949292813
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
| -rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index fbfee12be9..a6dfa475eb 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -1159,6 +1159,16 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct RecordSimplification(); return; } + } else if (input->IsIntConstant()) { + // Try to eliminate type conversion on int constant whose value falls into + // the range of the result type. + int32_t value = input->AsIntConstant()->GetValue(); + if (DataType::IsTypeConversionImplicit(value, result_type)) { + instruction->ReplaceWith(input); + instruction->GetBlock()->RemoveInstruction(instruction); + RecordSimplification(); + return; + } } } |
