We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c5dcb51 commit 074afa1Copy full SHA for 074afa1
1 file changed
test/dialects/scf/test_constprop.py
@@ -137,15 +137,7 @@ def impure_on_later_iter(x: int) -> int:
137
constprop = const.Propagate(_group)
138
frame, ret = constprop.run(impure_on_later_iter)
139
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"
+ [for_stmt] = [s for s in impure_on_later_iter.code.walk() if isinstance(s, scf.For)]
149
# The for-loop must NOT be in should_be_pure — it contains a
150
# conditionally-impure operation on a later iteration.
151
assert for_stmt not in frame.should_be_pure
0 commit comments