mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-25 06:48:22 -05:00
remove redundant div gcd patterns [run_process_replay] (#6076)
covered by generic div_folding
This commit is contained in:
@@ -284,9 +284,6 @@ constant_folder = PatternMatcher([
|
||||
# # div folding
|
||||
(NOp.var('x') // NOp.cvar('c'), lambda x,c:
|
||||
newx if 0 < c.arg and not dtypes.is_unsigned(x.dtype) and (newx:=div_folding(x,c.arg)) is not None else None),
|
||||
# mul add div
|
||||
(((NOp.cvar('c0')*NOp.var('x'))+NOp.var('x2')) // NOp.cvar('c1'), lambda x,x2,c0,c1:\
|
||||
x*(c0.arg//g)//(c1.arg//g) if c0.arg > 0 and c1.arg > 0 and (g:=math.gcd(c0.arg,c1.arg)) > 1 and g > x2.vmax.arg and x2.vmin.arg >= 0 else None),
|
||||
# ** mod **
|
||||
# apply mod to mod input
|
||||
(NOp.var('x') % NOp.cvar('c'), lambda x,c: newx%c if 0 < c.arg and (newx:=mod_folding(x,c.arg)) is not None else None),
|
||||
|
||||
Reference in New Issue
Block a user