[clang] [Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (PR #140532)

Walter J.T.V via cfe-commits cfe-commits at lists.llvm.org
Wed May 21 02:07:03 PDT 2025


eZWALT wrote:

> @alexey-bataev It’s true that NumGeneratedLoops is used throughout the existing OpenMP loop transformation infrastructure. While in some cases its usage could potentially be replaced by NumGeneratedLoopNests (especially when only checking for values like 0 or 1), the two variables convey distinct semantic information.
> 
> NumGeneratedLoops refers to the number of individual loops produced, while NumGeneratedLoopNests captures the structure of nested loops. For current and future transformations, having access to both could be important for representing complex constructs accurately.
> 
> Removing NumGeneratedLoops would require changes across the loop transformations logic it's not clear the benefit would justify that cost, particularly given the potential utility of retaining this semantic distinction.I’m not 100% certain all current transformations depend on that level of detail, but I believe it’s valuable to preserve until proven otherwise.

I've identified a case where `NumGeneratedLoops` is necessary and cannot be replaced by `NumGeneratedLoopNests`: the `permutation` clause of the `interchange` directive, e.g., permutation(2,1,...). In this transformation, we’re not interested in the number of top-level loop nests, but rather in how many individual loops exist within a single top-level nest, and how to reorder them. Let me know if i have clarified your doubts or if you want more examples, sometimes this kind of details are somewhat difficult to explain easily. 

https://github.com/llvm/llvm-project/pull/140532


More information about the cfe-commits mailing list