mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			372 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			372 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from opcodes import AND, SHL
 | 
						|
from rule import Rule
 | 
						|
from z3 import BitVec
 | 
						|
 | 
						|
"""
 | 
						|
Rule:
 | 
						|
AND(SHL(Z,X), SHL(Z,Y)) -> SHL(Z, AND(X,Y))
 | 
						|
"""
 | 
						|
 | 
						|
rule = Rule()
 | 
						|
 | 
						|
n_bits = 128
 | 
						|
 | 
						|
# Input vars
 | 
						|
X = BitVec('X', n_bits)
 | 
						|
Y = BitVec('Y', n_bits)
 | 
						|
Z = BitVec('Z', n_bits)
 | 
						|
 | 
						|
# Non optimized result
 | 
						|
nonopt = AND(SHL(Z,X), SHL(Z,Y))
 | 
						|
 | 
						|
# Optimized result
 | 
						|
opt = SHL(Z, AND(X,Y))
 | 
						|
 | 
						|
rule.check(nonopt, opt)
 |