remove redundant div gcd patterns [run_process_replay] (#6076)

covered by generic div_folding
This commit is contained in:
chenyu
2024-08-14 13:18:28 -04:00
committed by GitHub
parent 2dc586ffe5
commit de773b593e

View File

@@ -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),