[all-commits] [llvm/llvm-project] 912056: [Clang][OpenMP] Enable tile/unroll on iterator- an...
Michael Kruse via All-commits
all-commits at lists.llvm.org
Wed May 22 05:30:52 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9120562dfcc09cb4caf3052c6744049b4d9c8481
https://github.com/llvm/llvm-project/commit/9120562dfcc09cb4caf3052c6744049b4d9c8481
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2024-05-22 (Wed, 22 May 2024)
Changed paths:
M clang/include/clang/Sema/SemaOpenMP.h
M clang/lib/CodeGen/CGStmtOpenMP.cpp
M clang/lib/Sema/SemaOpenMP.cpp
M clang/test/OpenMP/tile_codegen.cpp
M clang/test/OpenMP/tile_codegen_for_dependent.cpp
M clang/test/OpenMP/tile_codegen_tile_for.cpp
M openmp/runtime/test/lit.cfg
A openmp/runtime/test/transform/tile/foreach.cpp
A openmp/runtime/test/transform/tile/iterfor.cpp
A openmp/runtime/test/transform/tile/parallel-wsloop-collapse-foreach.cpp
A openmp/runtime/test/transform/unroll/factor_foreach.cpp
A openmp/runtime/test/transform/unroll/factor_intfor.c
A openmp/runtime/test/transform/unroll/factor_iterfor.cpp
A openmp/runtime/test/transform/unroll/factor_parallel-wsloop-collapse-foreach.cpp
A openmp/runtime/test/transform/unroll/factor_parallel-wsloop-collapse-intfor.cpp
A openmp/runtime/test/transform/unroll/full_intfor.c
A openmp/runtime/test/transform/unroll/heuristic_intfor.c
A openmp/runtime/test/transform/unroll/partial_intfor.c
Log Message:
-----------
[Clang][OpenMP] Enable tile/unroll on iterator- and foreach-loops (#91459)
OpenMP loop transformation did not work on a for-loop using an iterator
or range-based for-loops. The first reason is that it combined the
iterator's type for generated loops with the type of `NumIterations` as
generated for any `OMPLoopBasedDirective` which is an integer. Fixed by
basing all generated loop variables on `NumIterations`.
Second, C++11 range-based for-loops include syntactic sugar that needs
to be executed before the loop. This additional code is now added to the
construct's Pre-Init lists.
Third, C++20 added an initializer statement to range-based for-loops
which is also added to the pre-init statement. PreInits used to be a
`DeclStmt` which made it difficult to add arbitrary statements from
`CXXRangeForStmt`'s syntactic sugar, especially the for-loops init
statement which does not need to be a declaration. Change it to be a
general `Stmt` that can be a `CompoundStmt` to hold arbitrary Stmts,
including DeclStmts. This also avoids the `PointerUnion` workaround used
by `checkTransformableLoopNest`.
End-to-end tests are added to verify the expected number and order of
loop execution and evaluations of expressions (such as iterator
dereference). The order and number of evaluations of expressions in
canonical loops is explicitly undefined by OpenMP but checked here for
clarification and for changes to be noticed.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list