Skip to content

Commit 074afa1

Browse files
johnzl-777claude
andcommitted
simplify scf.For lookup in early termination test
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c5dcb51 commit 074afa1

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

test/dialects/scf/test_constprop.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,7 @@ def impure_on_later_iter(x: int) -> int:
137137
constprop = const.Propagate(_group)
138138
frame, ret = constprop.run(impure_on_later_iter)
139139

140-
# The for-loop statement is in the first block of the callable region.
141-
for_stmt = None
142-
for block in impure_on_later_iter.callable_region.blocks:
143-
for stmt in block.stmts:
144-
if isinstance(stmt, scf.For):
145-
for_stmt = stmt
146-
break
147-
148-
assert for_stmt is not None, "Could not find scf.For in the IR"
140+
[for_stmt] = [s for s in impure_on_later_iter.code.walk() if isinstance(s, scf.For)]
149141
# The for-loop must NOT be in should_be_pure — it contains a
150142
# conditionally-impure operation on a later iteration.
151143
assert for_stmt not in frame.should_be_pure

0 commit comments

Comments
 (0)