Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mypyc/irbuild/for_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ def for_loop_helper_with_index(

builder.push_loop_stack(step_block, exit_block)

builder.goto_and_activate(condition_block)
if isinstance(length, Integer) and length.value > 0:
builder.goto(body_block)
builder.activate_block(condition_block)
else:
builder.goto_and_activate(condition_block)

for_gen.gen_condition()

builder.activate_block(body_block)
Expand Down
4 changes: 4 additions & 0 deletions mypyc/test-data/irbuild-lists.test
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ L0:
r0 = 'abc'
r1 = PyList_New(3)
r2 = 0
goto L2
L1:
r3 = r2 < 3 :: signed
if r3 goto L2 else goto L4 :: bool
Expand Down Expand Up @@ -690,6 +691,7 @@ L0:
r0 = 'abc'
r1 = PyList_New(3)
r2 = 0
goto L2
L1:
r3 = r2 < 3 :: signed
if r3 goto L2 else goto L4 :: bool
Expand Down Expand Up @@ -798,6 +800,7 @@ L0:
r0 = b'abc'
r1 = PyList_New(3)
r2 = 0
goto L2
L1:
r3 = r2 < 3 :: signed
if r3 goto L2 else goto L8 :: bool
Expand Down Expand Up @@ -952,6 +955,7 @@ L0:
r18 = CPyList_Extend(r10, r17)
r19 = PyList_New(13)
r20 = 0
goto L2
L1:
r21 = var_object_size r10
r22 = r20 < r21 :: signed
Expand Down
4 changes: 4 additions & 0 deletions mypyc/test-data/irbuild-tuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ L0:
r0 = 'abc'
r1 = PyTuple_New(3)
r2 = 0
goto L2
L1:
r3 = r2 < 3 :: signed
if r3 goto L2 else goto L4 :: bool
Expand Down Expand Up @@ -462,6 +463,7 @@ L0:
r0 = 'abc'
r1 = PyTuple_New(3)
r2 = 0
goto L2
L1:
r3 = r2 < 3 :: signed
if r3 goto L2 else goto L4 :: bool
Expand Down Expand Up @@ -570,6 +572,7 @@ L0:
r0 = b'abc'
r1 = PyTuple_New(3)
r2 = 0
goto L2
L1:
r3 = r2 < 3 :: signed
if r3 goto L2 else goto L8 :: bool
Expand Down Expand Up @@ -879,6 +882,7 @@ L0:
r18 = CPyList_Extend(r10, r17)
r19 = PyTuple_New(13)
r20 = 0
goto L2
L1:
r21 = var_object_size r10
r22 = r20 < r21 :: signed
Expand Down
Loading