From d46f29e128465678d9e8cc4254703f4efc286a5c Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Thu, 14 Mar 2019 16:30:11 +0100 Subject: [PATCH] Add bitshift optimizer tests --- .../remove_redundant_shift_masking.yul | 16 ++++++++++++++++ .../replace_too_large_shift.yul | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul create mode 100644 test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul new file mode 100644 index 000000000..89bc0ca67 --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul @@ -0,0 +1,16 @@ +{ + let a := and(0xff, shr(248, calldataload(0))) + let b := and(shr(248, calldataload(0)), 0xff) + let c := and(shr(249, calldataload(0)), 0xfa) + let d := and(shr(247, calldataload(0)), 0xff) +} +// ==== +// EVMVersion: >byzantium +// step: expressionSimplifier +// ---- +// { +// let a := shr(248, calldataload(0)) +// let b := shr(248, calldataload(0)) +// let c := and(shr(249, calldataload(0)), 0xfa) +// let d := and(shr(247, calldataload(0)), 0xff) +// } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul new file mode 100644 index 000000000..769c5489f --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul @@ -0,0 +1,16 @@ +{ + let a := shl(299, calldataload(0)) + let b := shr(299, calldataload(1)) + let c := shl(255, calldataload(2)) + let d := shr(255, calldataload(3)) +} +// ==== +// EVMVersion: >byzantium +// step: expressionSimplifier +// ---- +// { +// let a := 0 +// let b := 0 +// let c := shl(255, calldataload(2)) +// let d := shr(255, calldataload(3)) +// }