remove the wrong mod UOp pattern (#5847)

don't think we are hitting it because the stride construction, and it's wrong and not needed
This commit is contained in:
chenyu
2024-07-31 16:24:25 -04:00
committed by GitHub
parent 8174c438a3
commit c2ffcf6887
3 changed files with 2 additions and 1 deletions

View File

@@ -176,6 +176,7 @@ class TestSymbolic(unittest.TestCase):
def test_mod_mod(self):
self.helper_test_variable((Variable("a", 0, 31)%12)%4, 0, 3, "(a%4)")
self.helper_test_variable(((4*Variable("a", 0, 31)) % 12) % 4, 0, 0, "0")
self.helper_test_variable(((5*Variable("a", 0, 31)) % 12) % 5, 0, 4, "(((a*5)%12)%5)")
self.helper_test_variable((Variable("a", 0, 31) % 4) % 12, 0, 3, "(a%4)")
def test_mul_mul(self):

View File

@@ -236,6 +236,7 @@ class TestSymbolic(unittest.TestCase):
def test_mod_mod(self):
self.helper_test_variable((Variable("a", 0, 31)%12)%4, 0, 3, "(a%4)")
self.helper_test_variable(((4*Variable("a", 0, 31)) % 12) % 4, 0, 0, "0")
self.helper_test_variable(((5*Variable("a", 0, 31)) % 12) % 5, 0, 4, {"(((a*5)%12)%5)", "(((5*a)%12)%5)"})
self.helper_test_variable((Variable("a", 0, 31) % 4) % 12, 0, 3, "(a%4)")
def test_mul_mul(self):

View File

@@ -240,7 +240,6 @@ constant_folder = PatternMatcher([
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 mod
((NOp.var('x') % NOp.cvar('c0')) % NOp.cvar('c1'), lambda x,c0,c1: x % c0 if 0 < c0.arg < c1.arg else x % c1 if c0.arg % c1.arg == 0 else None),
(((NOp.var('x') * NOp.cvar('c0')) % NOp.cvar('c1')) % NOp.cvar('c0'), lambda x,c0,c1: x.const(0)),
# -(x+y) -> -x + -y
#(-(NOp.var("x") + NOp.var("y")), lambda x,y: (-x)+(-y)),
# (x*c0)+(x*c1) -> x*(c0+c1)