diff options
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index 5db8235e29..44d624883d 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -450,15 +450,22 @@ static bool TryReplaceShiftsByConstantWithTypeConversion(HBinaryOperation *instr bool is_signed = instruction->IsShr(); DataType::Type conv_type = is_signed ? source_integral_type : DataType::ToUnsigned(source_integral_type); + + DCHECK(DataType::IsTypeConversionImplicit(conv_type, instruction->GetResultType())); + HInstruction* shl_value = shl->GetLeft(); HBasicBlock *block = instruction->GetBlock(); - HTypeConversion* new_conversion = - new (block->GetGraph()->GetAllocator()) HTypeConversion(conv_type, shl_value); - - DCHECK(DataType::IsTypeConversionImplicit(conv_type, instruction->GetResultType())); + // We shouldn't introduce new implicit type conversions during simplification. + if (DataType::IsTypeConversionImplicit(shl_value->GetType(), conv_type)) { + instruction->ReplaceWith(shl_value); + instruction->GetBlock()->RemoveInstruction(instruction); + } else { + HTypeConversion* new_conversion = + new (block->GetGraph()->GetAllocator()) HTypeConversion(conv_type, shl_value); + block->ReplaceAndRemoveInstructionWith(instruction, new_conversion); + } - block->ReplaceAndRemoveInstructionWith(instruction, new_conversion); shl->GetBlock()->RemoveInstruction(shl); return true; |