Emit !llvm.mem.parallel_loop_access metadata for memory accesses even if the parallel loop is not the top on the loop stack.
Fixes llvm.org/PR37558.
Differential D48808
[CodeGen] Emit parallel_loop_access for each loop in the loop stack. Meinersbur on Jun 30 2018, 10:03 PM. Authored by
Details Emit !llvm.mem.parallel_loop_access metadata for memory accesses even if the parallel loop is not the top on the loop stack. Fixes llvm.org/PR37558.
Diff Detail
Event TimelineComment Actions I don't think that this is the intended behavior of the #pragma clang loop. it is better to ask the author of this pragma is this correct or not. Comment Actions It is the intended behavior that the memory accesses are independent with respect to the outer (annotated) loop (even if those accesses are within an inner loop). They're not independent with respect to the inner loop unless that loop is also annotated. Thus, this looks correct. Michael, can you please add a test with two inner loops, one where more than one is annotated, and one where only the outer loop is annotated? It's not clear to me that I->setMetadata will do the right thing here in the former case. Comment Actions I understand it as the intended behavior of the assume_safety option (also used for #pragma omp simd). @tyler.nowicki What is the intended behaviour? Comment Actions Hi Michael, Hal, Sorry it has been a while since I looked at this. My memory is a little If we can vectorize non-inner loop instructions then what behavior would My opinion is that for consistency 'assume_safety' and similar options Tyler Nowicki Comment Actions The test case pragma-loop-safety-nested.cpp check the case where the outer loop is annotated. Iterating over Active will iterate from outer to inner loops, meaning I->setMetadata will overwrite the annotation of the outermost loop (which IMHO is the most useful behaviour). Since it not possible to add multiple !llvm.mem.parallel_loop_access annotation, we cannot annotate multiple loops. Comment Actions We specifically defined the metadata to support nested loops. The LangRef says, "The llvm.mem.parallel_loop_access metadata refers to a loop identifier, or metadata containing a list of loop identifiers for nested loops." To handle nested loops, we need to make the instruction metadata point to a list of loop IDs. Comment Actions Thanks for pointing me to it. I've not seen parallel_loop_access pointing to a list, so I didn't know it was possible. Comment Actions Yea, well, we defined it to be possible. As to whether the backend will actually correctly read the metadata in that format, I don't know. |