diff options
author | chriseth <chris@ethereum.org> | 2018-10-12 03:20:04 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-10-12 21:20:06 +0800 |
commit | 1e06422589215f730ede6fc27b0baf09d5f0c744 (patch) | |
tree | 4e65febdb2169f47b4ca17d39538dd3cbab898db | |
parent | 1d312c8e4073e2e7ce9a23a721013942e1e5c727 (diff) | |
download | dexon-solidity-1e06422589215f730ede6fc27b0baf09d5f0c744.tar.gz dexon-solidity-1e06422589215f730ede6fc27b0baf09d5f0c744.tar.zst dexon-solidity-1e06422589215f730ede6fc27b0baf09d5f0c744.zip |
Also split constants.
5 files changed, 57 insertions, 34 deletions
diff --git a/libjulia/optimiser/ExpressionSplitter.cpp b/libjulia/optimiser/ExpressionSplitter.cpp index 4448a15b..f189f563 100644 --- a/libjulia/optimiser/ExpressionSplitter.cpp +++ b/libjulia/optimiser/ExpressionSplitter.cpp @@ -89,7 +89,7 @@ void ExpressionSplitter::operator()(Block& _block) void ExpressionSplitter::outlineExpression(Expression& _expr) { - if (_expr.type() != typeid(FunctionalInstruction) && _expr.type() != typeid(FunctionCall)) + if (_expr.type() == typeid(Identifier)) return; visit(_expr); diff --git a/test/libjulia/yulOptimizerTests/expressionSplitter/control_flow.yul b/test/libjulia/yulOptimizerTests/expressionSplitter/control_flow.yul index 5cc5a17d..d021129f 100644 --- a/test/libjulia/yulOptimizerTests/expressionSplitter/control_flow.yul +++ b/test/libjulia/yulOptimizerTests/expressionSplitter/control_flow.yul @@ -10,24 +10,31 @@ // ---- // expressionSplitter // { -// let x := calldataload(0) -// let _1 := add(x, 2) -// let _2 := mul(_1, 3) -// if _2 +// let _1 := 0 +// let x := calldataload(_1) +// let _2 := 3 +// let _3 := 2 +// let _4 := add(x, _3) +// let _5 := mul(_4, _2) +// if _5 // { // for { // let a := 2 // } // lt(a, mload(a)) // { -// let _3 := mul(a, 2) -// a := add(a, _3) +// let _6 := 2 +// let _7 := mul(a, _6) +// a := add(a, _7) // } // { -// let _4 := add(a, 2) -// let b := mul(_4, 4) -// let _5 := mul(b, 2) -// sstore(b, _5) +// let _8 := 4 +// let _9 := 2 +// let _10 := add(a, _9) +// let b := mul(_10, _8) +// let _11 := 2 +// let _12 := mul(b, _11) +// sstore(b, _12) // } // } // } diff --git a/test/libjulia/yulOptimizerTests/expressionSplitter/inside_function.yul b/test/libjulia/yulOptimizerTests/expressionSplitter/inside_function.yul index 8623f15d..53bbcea7 100644 --- a/test/libjulia/yulOptimizerTests/expressionSplitter/inside_function.yul +++ b/test/libjulia/yulOptimizerTests/expressionSplitter/inside_function.yul @@ -8,17 +8,22 @@ // ---- // expressionSplitter // { -// let _1 := mload(7) -// let _2 := f(0, _1) -// let x := mul(_2, 3) +// let _1 := 3 +// let _2 := 7 +// let _3 := mload(_2) +// let _4 := 0 +// let _5 := f(_4, _3) +// let x := mul(_5, _1) // function f(a, b) -> c // { -// let _3 := add(b, c) -// let _4 := mload(_3) -// c := mul(a, _4) +// let _6 := add(b, c) +// let _7 := mload(_6) +// c := mul(a, _7) // } -// let _5 := mload(2) -// let _6 := mload(2) -// let _7 := f(_6, _5) -// sstore(x, _7) +// let _8 := 2 +// let _9 := mload(_8) +// let _10 := 2 +// let _11 := mload(_10) +// let _12 := f(_11, _9) +// sstore(x, _12) // } diff --git a/test/libjulia/yulOptimizerTests/expressionSplitter/switch.yul b/test/libjulia/yulOptimizerTests/expressionSplitter/switch.yul index bda613b7..aee7976f 100644 --- a/test/libjulia/yulOptimizerTests/expressionSplitter/switch.yul +++ b/test/libjulia/yulOptimizerTests/expressionSplitter/switch.yul @@ -9,17 +9,25 @@ // expressionSplitter // { // let x := 8 -// let _1 := calldataload(0) -// let _2 := add(2, _1) -// switch _2 +// let _1 := 0 +// let _2 := calldataload(_1) +// let _3 := 2 +// let _4 := add(_3, _2) +// switch _4 // case 0 { -// let _3 := mload(2) -// sstore(0, _3) +// let _5 := 2 +// let _6 := mload(_5) +// let _7 := 0 +// sstore(_7, _6) // } // default { -// let _4 := mload(3) -// mstore(0, _4) +// let _8 := 3 +// let _9 := mload(_8) +// let _10 := 0 +// mstore(_10, _9) // } -// let _5 := mload(3) -// x := add(_5, 4) +// let _11 := 4 +// let _12 := 3 +// let _13 := mload(_12) +// x := add(_13, _11) // } diff --git a/test/libjulia/yulOptimizerTests/expressionSplitter/trivial.yul b/test/libjulia/yulOptimizerTests/expressionSplitter/trivial.yul index 632855a5..bff70cd8 100644 --- a/test/libjulia/yulOptimizerTests/expressionSplitter/trivial.yul +++ b/test/libjulia/yulOptimizerTests/expressionSplitter/trivial.yul @@ -4,8 +4,11 @@ // ---- // expressionSplitter // { -// let _1 := mload(3) -// let _2 := calldataload(2) -// let _3 := add(_2, _1) -// mstore(_3, 8) +// let _1 := 8 +// let _2 := 3 +// let _3 := mload(_2) +// let _4 := 2 +// let _5 := calldataload(_4) +// let _6 := add(_5, _3) +// mstore(_6, _1) // } |