vectorized input in div_and_mod_folding returns None [pr] (#8041)

This commit is contained in:
chenyu
2024-12-04 13:36:41 -05:00
committed by GitHub
parent ff6def9ffb
commit 5c2b1089b2

View File

@@ -871,6 +871,7 @@ def split_uop(x:UOp, sep:Ops):
def div_and_mod_folding(x: UOp, c: int, which: Literal[Ops.MOD, Ops.IDIV], split_rem: bool=False) -> Optional[UOp]:
# simplify x // c or x % c, None means no change, c must be > 0
assert c > 0
if x.dtype.count > 1: return None
# simple cancel div/mod case
if (q:=x.vmin//c) == (x.vmax//c):
if which is Ops.MOD: return x - q*c