fix special vmax when arg is UOp (#11930)

This commit is contained in:
Sieds Lykles
2025-08-31 06:54:39 +02:00
committed by GitHub
parent 0bacd9fc9b
commit d3252ccd85
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ class TestVminVmaxProperties(unittest.TestCase):
def test_vmin_vmax_variable_inside_special(self):
uop = UOp(Ops.SPECIAL, dtypes.int, arg=('gidx0', UOp(Ops.DEFINE_VAR, dtypes.int, arg=('i', 1, 10))))
self.assertEqual(uop.vmin, 0)
self.assertEqual(uop.vmax, 10)
self.assertEqual(uop.vmax, 9)
def test_vmin_vmax_multiplication_0_inf(self):
# vmin and vmax for multiplication with a variable
+1 -1
View File
@@ -555,7 +555,7 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
if self.op is Ops.BIND: return self.src[0]._min_max # ignore the bound value
if self.op in {Ops.UNROLL, Ops.VECTORIZE}: return min(x.vmin for x in self.src), max(x.vmax for x in self.src)
# TODO: Ops.SPECIAL is Ops.DEFINE_VAR
if self.op is Ops.SPECIAL: return 0, self.arg[1]-1 if isinstance(self.arg[1], int) else self.arg[1].vmax
if self.op is Ops.SPECIAL: return 0, self.arg[1]-1 if isinstance(self.arg[1], int) else self.arg[1].vmax-1
if self.op is Ops.CONST: return self.arg, self.arg
if self.op is Ops.VCONST: return (min(self.arg), max(self.arg))
# TODO: CAST to bool/unsigned is not monotone, still some case can be simplified