diff options
Diffstat (limited to 'compiler/optimizing/constant_folding.cc')
-rw-r--r-- | compiler/optimizing/constant_folding.cc | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc index ec0cc3e98b..b7a92b5ae5 100644 --- a/compiler/optimizing/constant_folding.cc +++ b/compiler/optimizing/constant_folding.cc @@ -55,20 +55,20 @@ void HConstantFolding::Run() { if (inst->IsBinaryOperation()) { // Constant folding: replace `op(a, b)' with a constant at // compile time if `a' and `b' are both constants. - HConstant* constant = - inst->AsBinaryOperation()->TryStaticEvaluation(); + HConstant* constant = inst->AsBinaryOperation()->TryStaticEvaluation(); if (constant != nullptr) { - inst->GetBlock()->ReplaceAndRemoveInstructionWith(inst, constant); + inst->ReplaceWith(constant); + inst->GetBlock()->RemoveInstruction(inst); } else { inst->Accept(&simplifier); } } else if (inst->IsUnaryOperation()) { // Constant folding: replace `op(a)' with a constant at compile // time if `a' is a constant. - HConstant* constant = - inst->AsUnaryOperation()->TryStaticEvaluation(); + HConstant* constant = inst->AsUnaryOperation()->TryStaticEvaluation(); if (constant != nullptr) { - inst->GetBlock()->ReplaceAndRemoveInstructionWith(inst, constant); + inst->ReplaceWith(constant); + inst->GetBlock()->RemoveInstruction(inst); } } else if (inst->IsDivZeroCheck()) { // We can safely remove the check if the input is a non-null constant. @@ -173,9 +173,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitRem(HRem* instruction) { // REM dst, src, src // with // CONSTANT 0 - ArenaAllocator* allocator = GetGraph()->GetArena(); - block->ReplaceAndRemoveInstructionWith(instruction, - HConstant::NewConstant(allocator, type, 0)); + instruction->ReplaceWith(GetGraph()->GetConstant(type, 0)); + block->RemoveInstruction(instruction); } } @@ -195,7 +194,6 @@ void InstructionWithAbsorbingInputSimplifier::VisitSub(HSub* instruction) { } HBasicBlock* block = instruction->GetBlock(); - ArenaAllocator* allocator = GetGraph()->GetArena(); // We assume that GVN has run before, so we only perform a pointer // comparison. If for some reason the values are equal but the pointers are @@ -208,8 +206,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitSub(HSub* instruction) { // CONSTANT 0 // Note that we cannot optimise `x - x` to `0` for floating-point. It does // not work when `x` is an infinity. - block->ReplaceAndRemoveInstructionWith(instruction, - HConstant::NewConstant(allocator, type, 0)); + instruction->ReplaceWith(GetGraph()->GetConstant(type, 0)); + block->RemoveInstruction(instruction); } } @@ -225,10 +223,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitXor(HXor* instruction) { // CONSTANT 0 Primitive::Type type = instruction->GetType(); HBasicBlock* block = instruction->GetBlock(); - ArenaAllocator* allocator = GetGraph()->GetArena(); - - block->ReplaceAndRemoveInstructionWith(instruction, - HConstant::NewConstant(allocator, type, 0)); + instruction->ReplaceWith(GetGraph()->GetConstant(type, 0)); + block->RemoveInstruction(instruction); } } |