[PATCH] D103907: [LV] Parallel annotated loop does not imply all loads can be hoisted.

Joachim Meyer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 09:19:20 PDT 2021


fodinabor created this revision.
fodinabor added reviewers: SjoerdMeijer, Meinersbur, Ayal, Pierre-vh, dmgreen, rengolin, fhahn, samparker, gilr, pjaaskel.
Herald added subscribers: Naghasan, Anastasia, hiraditya.
fodinabor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As noted in https://bugs.llvm.org/show_bug.cgi?id=46666, the current behavior of assuming if-conversion safety if a loop is annotated parallel (`!llvm.loop.parallel_accesses`), is not expectable, the documentation for this behavior was since removed from the LangRef again, and can lead to invalid reads.
This was observed in POCL (https://github.com/pocl/pocl/issues/7571) and would require similar workarounds in current work at hipSYCL.

The question remains why this was initially added and what the implications of removing this optimization would be.
Do we need an alternative mechanism to propagate the information about legality of if-conversion?
Or is the idea that conditional loads in `#pragma clang loop vectorize(assume_safety)` can be executed unmasked without additional checks flawed in general?
I think this implication is not part of what a user of that pragma (and corresponding metadata) would expect and thus dangerous.

Only two additional tests failed, which are adapted in this patch. Depending on the further direction force-ifcvt.ll should be removed or further adapted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103907

Files:
  llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
  llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
  llvm/test/Transforms/LoopVectorize/X86/force-ifcvt.ll
  llvm/test/Transforms/LoopVectorize/X86/tail_folding_and_assume_safety.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103907.350624.patch
Type: text/x-patch
Size: 5351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210608/6bfb0938/attachment.bin>


More information about the llvm-commits mailing list