Skip to content

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

Open
@orbiri

Description

@orbiri

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    IR designConsiderations around the design of ClangIRenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions