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

Add Region Argument Support To Control Flow Ops (a-la-SCFOps) #1267

Open
orbiri opened this issue Jan 4, 2025 · 1 comment
Open

Add Region Argument Support To Control Flow Ops (a-la-SCFOps) #1267

orbiri opened this issue Jan 4, 2025 · 1 comment
Labels
enhancement New feature or request IR design Considerations around the design of ClangIR

Comments

@orbiri
Copy link
Collaborator

orbiri commented Jan 4, 2025

Today, all control-flow operations are pretty lean - they would contain several regions with clear semantics on the "flow" between these regions.

Something that is missing in all loop-like operations is the ability to add initial-value region arguments. Adding support for that would allow multiple things:

  1. Generating CIR loops from non-control-flow is easier and does not require allocating temp variables (for example - generating the zero-initializer loop for arrays).
  2. Opening up the opportunity for mem2reg and other memory optimizations to be written on top of CIR. This is not possible otherwise as CIR currently relies on all loop-carried variables to be carried through the stack.
  3. Possibly lowering from AST / lifting in CIR some information to re-construct higher-level semantics the user intended (e.g. translating simple for loops into construct similar to scf.for: ... = scf.for %iv = %lb to %ub step %step {...). Without first having the loop-carried information described as region arguments it would be pretty difficult to reconstruct these constructs.

I would be happy to see this support come to life!

@orbiri orbiri added enhancement New feature or request IR design Considerations around the design of ClangIR labels Jan 4, 2025
@bcardosolopes
Copy link
Member

Sounds like a good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request IR design Considerations around the design of ClangIR
Projects
None yet
Development

No branches or pull requests

2 participants