remove redundant UOps max folding [run_process_replay] (#5762)

all covered by generic max folding
This commit is contained in:
chenyu 2024-07-27 16:46:51 -04:00 committed by GitHub
parent 05748e5a84
commit 3c79faaf77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 0 additions and 6 deletions

View File

@ -193,12 +193,6 @@ constant_folder = PatternMatcher([
(NOp.cvar("c1") - (NOp.var("x") + NOp.cvar("c2")), lambda c1, c2, x: (c1-c2)-x), # c1 - (x + c2) -> (c1-c2) - x
# max folding
(NOp.max(NOp.var('x'), NOp.var('y')), lambda x,y: x if x.vmin.arg >= y.vmax.arg else y if x.vmax.arg <= y.vmin.arg else None),
# max on special can go away (TODO: special should be variable, same thing applies)
(NOp.max(NOp.cvar('c'), NOp(UOps.SPECIAL, name="s")+NOp.cvar('c2')), lambda c,s,c2: (s+c2) if 0 >= c.arg else None), # TODO: generic
(NOp.max(NOp.cvar('c'), -(NOp(UOps.SPECIAL, name="s")+NOp.cvar('c2'))), lambda c,s,c2: -(s+c2) if -(s.arg[1]-1+c2.arg) >= c.arg else None),
# max on range can go away (ugh: copy of SPECIAL, and with/without const)
(NOp.max(NOp.cvar('c'), NOp(UOps.RANGE, name="s")+NOp.cvar('c2')), lambda c,s,c2: (s+c2) if s.src[0].arg >= c.arg else None), # TODO: generic
(NOp.max(NOp.cvar('c'), -(NOp(UOps.RANGE, name="s")+NOp.cvar('c2'))), lambda c,s,c2: -(s+c2) if -(s.src[1].arg-1+c2.arg) >= c.arg else None),
# const rules
(NOp(UOps.GEP, src=(NOp.cvar("c"),), name="root"), lambda root, c: root.const(c.arg)),
(UPat(UOps.CAST, name="root", src=UPat(UOps.CONST, name="c")), lambda root, c: root.const(c.arg)),