aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2016-10-25 19:38:37 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2016-11-30 19:16:43 +0800
commit25160bfc26cd5ae4b5104625caba41c1533614ba (patch)
tree931d52540abeefdb0f1a7ec7efce26cff9d13193
parentf70f8cf06aea5dcd44b6256b040e05d2a3f7045d (diff)
downloaddexon-solidity-25160bfc26cd5ae4b5104625caba41c1533614ba.tar.gz
dexon-solidity-25160bfc26cd5ae4b5104625caba41c1533614ba.tar.zst
dexon-solidity-25160bfc26cd5ae4b5104625caba41c1533614ba.zip
Add optimiser rule for SUB with 0
-rw-r--r--libevmasm/ExpressionClasses.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libevmasm/ExpressionClasses.cpp b/libevmasm/ExpressionClasses.cpp
index e32b2da2..cb327252 100644
--- a/libevmasm/ExpressionClasses.cpp
+++ b/libevmasm/ExpressionClasses.cpp
@@ -245,17 +245,18 @@ Rules::Rules()
// invariants involving known constants
{{Instruction::ADD, {X, 0}}, [=]{ return X; }},
+ {{Instruction::SUB, {X, 0}}, [=]{ return X; }},
{{Instruction::MUL, {X, 1}}, [=]{ return X; }},
{{Instruction::DIV, {X, 1}}, [=]{ return X; }},
{{Instruction::SDIV, {X, 1}}, [=]{ return X; }},
{{Instruction::OR, {X, 0}}, [=]{ return X; }},
{{Instruction::XOR, {X, 0}}, [=]{ return X; }},
{{Instruction::AND, {X, ~u256(0)}}, [=]{ return X; }},
+ {{Instruction::AND, {X, 0}}, [=]{ return u256(0); }},
{{Instruction::MUL, {X, 0}}, [=]{ return u256(0); }},
{{Instruction::DIV, {X, 0}}, [=]{ return u256(0); }},
{{Instruction::MOD, {X, 0}}, [=]{ return u256(0); }},
{{Instruction::MOD, {0, X}}, [=]{ return u256(0); }},
- {{Instruction::AND, {X, 0}}, [=]{ return u256(0); }},
{{Instruction::OR, {X, ~u256(0)}}, [=]{ return ~u256(0); }},
{{Instruction::EQ, {X, 0}}, [=]() -> Pattern { return {Instruction::ISZERO, {X}}; } },
// operations involving an expression and itself