mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	peepopt shiftadd: Only match for sufficiently small constant widths
This addresses issue #4445
This commit is contained in:
		
							parent
							
								
									a55e8594b7
								
							
						
					
					
						commit
						41aaaa153e
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
					@ -53,6 +53,11 @@ match add
 | 
				
			||||||
	select port(add, constport).is_fully_const()
 | 
						select port(add, constport).is_fully_const()
 | 
				
			||||||
	define <IdString> varport (constport == \A ? \B : \A)
 | 
						define <IdString> varport (constport == \A ? \B : \A)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// only optimize for constants up to a fixed width. this prevents cases
 | 
				
			||||||
 | 
						// with a blowup in internal term size and prevents larger constants being
 | 
				
			||||||
 | 
						// casted to int incorrectly
 | 
				
			||||||
 | 
						select (GetSize(port(add, constport)) <= 24)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// if a value of var is able to wrap the output, the transformation might give wrong results
 | 
						// if a value of var is able to wrap the output, the transformation might give wrong results
 | 
				
			||||||
	// an addition/substraction can at most flip one more bit than the largest operand (the carry bit)
 | 
						// an addition/substraction can at most flip one more bit than the largest operand (the carry bit)
 | 
				
			||||||
	// as long as the output can show this bit, no wrap should occur (assuming all signed-ness make sense)
 | 
						// as long as the output can show this bit, no wrap should occur (assuming all signed-ness make sense)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue