store ranges aren't needed anymore

This commit is contained in:
2025-10-10 15:21:37 +08:00
parent 9ec77ff587
commit 3d760bba51
2 changed files with 4 additions and 1 deletions
+2
View File
@@ -99,4 +99,6 @@ class CFGContext:
pm_control_flow_starts = PatternMatcher([
(UPat((Ops.RANGE, Ops.IF), src=(UPat(),), name="x"), lambda ctx,x: x.replace(src=x.src+(y,)) if (y:=ctx.edges.get(x)) is not None else None),
(UPat(Ops.IF, src=(UPat(), UPat(Ops.BARRIER)), name="x"), lambda ctx,x: x.replace(src=x.src+(y,)) if (y:=ctx.edges.get(x)) is not None else None),
# remove ranges from STORE. keep NOOP since they determine ordering
(UPat(Ops.STORE, name="s"), lambda s: s.replace(src=s.src[0:2]+tuple([x for x in s.src[2:] if x.op not in {Ops.RANGE, Ops.CONST}]))),
])
+2 -1
View File
@@ -235,7 +235,8 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
ret: dict[UOp, None] = {}
if self.op is Ops.ENDRANGE:
for s in self.src[1:]: ret.update(s.ranges)
assert self.src[0] not in ret
# NOTE: the ended range should always be in the ranges
if self.src[0] in ret: del ret[self.src[0]]
elif self.op in range_start.keys():
for s in self.src[:range_start[self.op]]: ret.update(s.ranges)
for s in UOp.sink(*self.src[range_start[self.op]:]).ranges: