Open
Description
MWE:
from kirin.prelude import structural_no_opt
from kirin.passes import Fold
@structural_no_opt
def main(n: int):
x = 0
if x == n:
x += 1
elif x == n+1:
x += 3
return x
main.print()
Fold(main.dialects)(main)
main.print()
Output:
func.func main(!py.int) -> !Any {
^0(%main_self, %n):
│ %x = py.constant.constant 0 : !py.int
│ func.return %x
} // func.func main
Things work correctly if you replace the elif
by another if
, but it's not technically identical since x
is updated in-place which might lead to the second if
to be True.
.