mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6943 from ethereum/opcodeFix
Fix comparison opcodes and minor errors in proof scripts.
This commit is contained in:
commit
e78500a199
@ -15,11 +15,8 @@ n_bits = 32
|
||||
X = BitVec('X', n_bits)
|
||||
Y = BitVec('Y', n_bits)
|
||||
|
||||
# Constants
|
||||
ONE = BitVecVal(1, n_bits)
|
||||
|
||||
# Non optimized result
|
||||
nonopt = DIV(X, SHL(Y, ONE))
|
||||
nonopt = DIV(X, SHL(Y, 1))
|
||||
|
||||
# Optimized result
|
||||
opt = SHR(Y, X)
|
||||
|
@ -16,14 +16,11 @@ n_bits = 64
|
||||
X = BitVec('X', n_bits)
|
||||
Y = BitVec('Y', n_bits)
|
||||
|
||||
# Constants
|
||||
ONE = BitVecVal(1, n_bits)
|
||||
|
||||
# Requirements
|
||||
|
||||
# Non optimized result
|
||||
nonopt_1 = MUL(X, SHL(Y, ONE))
|
||||
nonopt_2 = MUL(SHL(X, ONE), Y)
|
||||
nonopt_1 = MUL(X, SHL(Y, 1))
|
||||
nonopt_2 = MUL(SHL(X, 1), Y)
|
||||
|
||||
# Optimized result
|
||||
opt_1 = SHL(Y, X)
|
||||
|
@ -33,7 +33,7 @@ nonopt = SHL(B, SHR(A, X))
|
||||
Mask = SHL(B, SHR(A, Int2BV(IntVal(-1), n_bits)))
|
||||
opt = If(
|
||||
UGT(A, B),
|
||||
AND(SHR(a - b, x), Mask),
|
||||
AND(SHR(A - B, X), Mask),
|
||||
If(
|
||||
UGT(B, A),
|
||||
AND(SHL(B - A, X), Mask),
|
||||
|
@ -22,16 +22,19 @@ def SMOD(x, y):
|
||||
return If(y == 0, 0, x % y)
|
||||
|
||||
def LT(x, y):
|
||||
return ULT(x, y)
|
||||
return If(ULT(x, y), BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
||||
|
||||
def GT(x, y):
|
||||
return UGT(x, y)
|
||||
return If(UGT(x, y), BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
||||
|
||||
def SLT(x, y):
|
||||
return x < y
|
||||
return If(x < y, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
||||
|
||||
def SGT(x, y):
|
||||
return x > y
|
||||
return If(x > y, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
||||
|
||||
def ISZERO(x):
|
||||
return If(x == 0, BitVecVal(1, x.size()), BitVecVal(0, x.size()))
|
||||
|
||||
def AND(x, y):
|
||||
return x & y
|
||||
|
Loading…
Reference in New Issue
Block a user