-
Notifications
You must be signed in to change notification settings - Fork 28
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
New transformation to replace a single-trip loop with an assignment to the loop variable #2738
Comments
Since most of the implementation is given in the issue description, this could be a good, self-contained issue for a new person to tackle. |
Note, if the body of the loop doesn't contain any CodeBlocks then we could go one better and replace all References to the loop variable with the value supplied to the transformation, i.e. "1" in the example given above. |
I believe we recently discussed to generalising the replace_induction_variables_trans? That would be another use case for a more generalised approach (the replace_induction... transformation just needs to restrict the constant replacement to the loop body) |
Oh yes, can you remember whether we had that discussion on GH and, if so, where? Do you mean that we'd use ReplaceInductionVariablesTrans to handle the substitution of the loop variable within the body? |
It was on teams, see message there. |
Here my comment on teams (which might be a bit long):
|
Given the reshaping of arrays being passed into the UM physics routines, there are many cases where there are loops over a dimension that we know, at build time, will have an extent of just unity. To help the compiler, it would therefore be good to remove all such loops and simply replace them with an assignment to the loop variable followed by the body of the loop:
Since this isn't entirely trivial, it would be good to have this as a transformation. I'm not sure what it should be called though. Perhaps
ReplaceSingleTripLoopTrans
?The text was updated successfully, but these errors were encountered: