solidity/test/formal/combine_byte_shr_2.py

28 lines
344 B
Python
Raw Normal View History

2020-06-04 09:11:53 +00:00
from rule import Rule
from opcodes import *
"""
byte(A, shr(B, X))
given A < B / 8
2020-06-04 09:11:53 +00:00
->
0
"""
rule = Rule()
n_bits = 256
# Input vars
X = BitVec('X', n_bits)
A = BitVec('A', n_bits)
B = BitVec('B', n_bits)
# Non optimized result
nonopt = BYTE(A, SHR(B, X))
# Optimized result
opt = 0
rule.require(ULT(A, DIV(B,8)))
rule.check(nonopt, opt)