Skip to content

Loop Normalization Utilities #1988

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

Merged
merged 4 commits into from
May 21, 2025
Merged

Loop Normalization Utilities #1988

merged 4 commits into from
May 21, 2025

Conversation

Berke-Ates
Copy link
Collaborator

This PR adds a loop normalization transformation, transforming loops to start at zero with a step size of one.

@Berke-Ates Berke-Ates requested a review from acalotoiu April 29, 2025 07:51
Copy link
Contributor

@acalotoiu acalotoiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@phschaad phschaad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a huge fan of having this kind of functionality be a pattern transformation. I am of the opinion that something like this is general-purpose enough that it warrants having a utility function somewhere that performs this operation. Whether the utility function can then be exposed through a pattern matching transformation can be discussed. However, there are a few reasons I am not in favor of it being a pattern matching transformation:

  1. The pattern is a single node - that's often not a good sign
  2. The operation is in my eyes primarily an optimization preparation, rather than an actual optimization itself. That means that when gathering applicable transformations for a program to improve performance, a transformation like this unnecessarily clutters the results.
  3. The operation is difficult to reuse. Given that it serves as an optimization preparation, that makes it so it is useful to apply from many other transformations / passes. Having it be a transformation means that doing so requires a lot of boiler-plate (setup a match, etc.).

As such, I would be in favor of having the same functionality given through 2 loop utility functions:

  1. Can a loop be normalized
  2. Normalize a loop

This would also make it possible to expose these functions through the LoopRegion's own API easily.

@Berke-Ates Berke-Ates requested a review from phschaad May 20, 2025 10:47
Copy link
Collaborator

@phschaad phschaad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the change, this is exactly what I had in mind. Looks good to me!

@phschaad phschaad added this pull request to the merge queue May 21, 2025
Merged via the queue into main with commit 4333176 May 21, 2025
10 checks passed
@phschaad phschaad deleted the loop_normalize branch May 21, 2025 08:47
@phschaad phschaad changed the title LoopNormalization Transformation Loop Normalization Utilities May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants