[llvm] [LoopInfo] Don't recognize loop as parallel if it stores to out-of-loop alloca (PR #180551)

Julius Ikkala via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 05:54: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.
----------------
juliusikkala wrote:

I wrote that with the assumption that `llvm.access.group` should not privatize `alloca`. I did that because I'm starting to think that we should _not_ privatize with `llvm.access.group` to allow users who know what they are doing to continue using `alloca` without anything new being generated. IMO the privatization metadata should probably be a different one handled in a different pass.

Our use case for privatization requires being able to retain privatized entries between separate loops. For that to work, I think we'll need more information than `llvm.access.group` can provide. That use case is also independent of the vectorization factor, and instead cares about the maximum trip count of the involved loops, which must be known ahead of time for all loops involved as we would not be able to retain entries across loops otherwise.

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


More information about the llvm-commits mailing list