Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support continue in loops #708

Closed
yuanming-hu opened this issue Apr 5, 2020 · 4 comments
Closed

Support continue in loops #708

yuanming-hu opened this issue Apr 5, 2020 · 4 comments
Assignees
Labels
feature request Suggest an idea on this project welcome contribution

Comments

@yuanming-hu
Copy link
Member

Concisely describe the proposed feature
It would be good to support continue in loops. E.g.,

@ti.kernel
def test():
     for i in x:
        if x[i] < 0:       
            continue # skip the rest of this loop body
        x[i] -= 1

Note that there are a few different cases: parallel range/struct for loops, serial range for loops, and while loops. However, the semantics is the same: jump to the end of the loop body so that the next iteration can start after this instruction.

Describe the solution you'd like (if any)

  • Add FrontendContinueStmt and ContinueStmt
  • Modify Python frontend
  • Modify lower_ast, ir_printer etc.
  • Implement the statement in each backend
@yuanming-hu yuanming-hu added feature request Suggest an idea on this project welcome contribution labels Apr 5, 2020
@k-ye
Copy link
Member

k-ye commented Apr 5, 2020

In the parallel case, is this the same as just returning from that struct_for/range_for task?

@yuanming-hu
Copy link
Member Author

yuanming-hu commented Apr 5, 2020

Right, just a jump to the loop body (if you are using SSA + CFG as in LLVM), or simply a return (in the parallel loop_body_function)/continue in serial loops in source-2-source.

@k-ye
Copy link
Member

k-ye commented Apr 5, 2020

Taking this. I haven't been able to work on IR for a while, and need to catch up..

@k-ye
Copy link
Member

k-ye commented Apr 7, 2020

Closed by #716

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Suggest an idea on this project welcome contribution
Projects
None yet
Development

No branches or pull requests

2 participants