diff options
author | Martin Holst Swende <martin@swende.se> | 2018-03-08 20:48:19 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-03-08 20:48:19 +0800 |
commit | 4871e25f5fe8d58344f5267ef197662dde018d21 (patch) | |
tree | ad4cb58d8506a9e93eb2240b53028e7f305bc09b /core/vm/instructions_test.go | |
parent | 85d5f2c661cd9461e64d6a224076ebc627e14a55 (diff) | |
download | dexon-4871e25f5fe8d58344f5267ef197662dde018d21.tar.gz dexon-4871e25f5fe8d58344f5267ef197662dde018d21.tar.zst dexon-4871e25f5fe8d58344f5267ef197662dde018d21.zip |
core/vm: optimize eq, slt, sgt and iszero + tests (#16047)
* vm: optimize eq, slt, sgt and iszero + tests
* core/vm: fix error in slt/sgt, found by vmtests. Added testcase
* core/vm: make slt/sgt cleaner
Diffstat (limited to 'core/vm/instructions_test.go')
-rw-r--r-- | core/vm/instructions_test.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index eef4328bd..134363bb7 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -161,6 +161,7 @@ func TestSAR(t *testing.T) { func TestSGT(t *testing.T) { tests := []twoOperandTest{ + {"0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"}, {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"}, {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"}, @@ -171,6 +172,8 @@ func TestSGT(t *testing.T) { {"8000000000000000000000000000000000000000000000000000000000000001", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"}, {"8000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"}, {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"}, + {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "0000000000000000000000000000000000000000000000000000000000000001"}, + {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "0000000000000000000000000000000000000000000000000000000000000000"}, } testTwoOperandOp(t, tests, opSgt) } @@ -187,6 +190,8 @@ func TestSLT(t *testing.T) { {"8000000000000000000000000000000000000000000000000000000000000001", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"}, {"8000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"}, {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"}, + {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "0000000000000000000000000000000000000000000000000000000000000000"}, + {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "0000000000000000000000000000000000000000000000000000000000000001"}, } testTwoOperandOp(t, tests, opSlt) } @@ -349,7 +354,11 @@ func BenchmarkOpEq(b *testing.B) { opBenchmark(b, opEq, x, y) } - +func BenchmarkOpEq2(b *testing.B) { + x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff" + y := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201fffffffe" + opBenchmark(b, opEq, x, y) +} func BenchmarkOpAnd(b *testing.B) { x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" @@ -412,3 +421,7 @@ func BenchmarkOpSAR(b *testing.B) { opBenchmark(b, opSAR, x, y) } +func BenchmarkOpIsZero(b *testing.B) { + x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff" + opBenchmark(b, opIszero, x) +} |