[llvm] [LoopInfo] Don't recognize loop as parallel if it stores to out-of-loop alloca (PR #180551)
Pekka Jääskeläinen via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 16 05:37:11 PST 2026
================
@@ -8223,12 +8223,12 @@ this loop. Instructions that belong to multiple access groups are
considered having this property if at least one of the access groups
matches the ``llvm.loop.parallel_accesses`` list.
-If all memory-accessing instructions in a loop have
-``llvm.access.group`` metadata that each refer to one of the access
-groups of a loop's ``llvm.loop.parallel_accesses`` metadata, then the
-loop has no loop carried memory dependencies and is considered to be a
-parallel loop. If there is a loop-carried dependency, the behavior is
-undefined.
+If all memory-accessing instructions in a loop and all ``alloca`` instructions
+whose address range is being written to by instructions in the loop have
+``llvm.access.group`` metadata referring to one of the access groups of a loop's
+``llvm.loop.parallel_accesses`` metadata, then the loop has no loop carried
+memory dependencies and is considered to be a parallel loop. If there is a
+loop-carried dependency, the behavior is undefined.
----------------
pjaaskel wrote:
I think we need to describe how the annotated allocas are expected to be handled in case the loop in question is vectorized (or why not multithreaded). That is, the annotated allocas are expected to be replicated for each parallelized iteration instance of the loop. Thus this change impacts all passes that actually parallelize such loops, but should not impact other passes which potentially are unaware of the metadata. Perhaps worth mentioning in the release notes. Also please link to the Discourse thread.
https://github.com/llvm/llvm-project/pull/180551
More information about the llvm-commits
mailing list