From b6ffb6c8b7a581e1c3d0e7882be0d1606cc37509 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Thu, 24 Nov 2016 18:21:57 +0100 Subject: libevmasm: generalize ADDPOP optimization into ADDMODPOP etc --- libevmasm/PeepholeOptimiser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libevmasm') diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp index 104d9769..901e310e 100644 --- a/libevmasm/PeepholeOptimiser.cpp +++ b/libevmasm/PeepholeOptimiser.cpp @@ -68,14 +68,15 @@ struct AddPop { Instruction i0 = _in[0].instruction(); if (instructionInfo(i0).ret == 1 && - instructionInfo(i0).args == 2 && !SemanticInformation::invalidatesMemory(i0) && - !SemanticInformation::invalidatesStorage(i0) + !SemanticInformation::invalidatesStorage(i0) && + !SemanticInformation::altersControlFlow(i0) && + !instructionInfo(i0).sideEffects ) { - *_out = Instruction::POP; - *_out = Instruction::POP; - return true; + for (int j = 0; j < instructionInfo(i0).args; j++) + *_out = Instruction::POP; + return true; } } return false; -- cgit