From 2a8090d7973f559386d8e11d09641e766ec316a8 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 18 Aug 2021 18:27:57 +0200 Subject: [PATCH] New simplification rules. --- libevmasm/RuleList.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index 9f0b07fe1..fda7f0c7f 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -681,6 +681,22 @@ std::vector> simplificationRuleListPart8( // X - (A + Y) -> (X - Y) + (-A) Builtins::SUB(X, Builtins::ADD(A, Y)), [=]() -> Pattern { return Builtins::ADD(Builtins::SUB(X, Y), 0 - A.d()); } + }, { + // (X - A) - Y -> (X - Y) - A + Builtins::SUB(Builtins::SUB(X, A), Y), + [=]() -> Pattern { return Builtins::SUB(Builtins::SUB(X, Y), A); } + }, { + // (A - X) - Y -> A - (X + Y) + Builtins::SUB(Builtins::SUB(A, X), Y), + [=]() -> Pattern { return Builtins::SUB(A, Builtins::ADD(X, Y)); } + }, { + // X - (Y - A) -> (X - Y) + A + Builtins::SUB(X, Builtins::SUB(Y, A)), + [=]() -> Pattern { return Builtins::ADD(Builtins::SUB(X, Y), A.d()); } + }, { + // X - (A - Y) -> (X + Y) + (-A) + Builtins::SUB(X, Builtins::SUB(A, Y)), + [=]() -> Pattern { return Builtins::ADD(Builtins::ADD(X, Y), 0 - A.d()); } } }; return rules;