[PATCH] D57566: Refactor setAlreadyUnrolled() and setAlreadyVectorized().

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 22:36:07 PST 2019


Meinersbur created this revision.
Meinersbur added reviewers: hfinkel, hsaito, evstupac, etherzhhb.
Herald added a subscriber: dmgreen.
Herald added a project: LLVM.

Loop::setAlreadyUnrolled() and LoopVectorizeHints::setLoopAlreadyUnrolled() both add loop metadata that stops the same loop from being transformed multiple times. This patch merges both implementations.

In doing so we fix 3 potential issues:

- setLoopAlreadyUnrolled() keept the llvm.loop.vectorize/interleave.* metadata even though it will not be used anymore. This already caused problems such as http://llvm.org/PR40546. Change the behavior to the one of setAlreadyUnrolled which deletes this loop metadata.
- setAlreadyUnrolled() used to create a new LoopID by calling MDNode::get with nullptr as the first operand, then replacing it by the returned references using replaceOperandWith. It is possible that MDNode::get would instead return an existing node (due to de-duplication) that then gets modified. To avoid, use MDNode::getDistinct.
- LoopVectorizeHints::matchesHintMetadataName() only compares the suffix of the attribute to set the new value for. That is, when called with "enable", would erase attributes such as "llvm.loop.unroll.enable", "llvm.loop.vectorize.enable" and "llvm.loop.distribute.enable" instead of such the one to replace. Fortunately, function was only called with "isvectorized".


Repository:
  rL LLVM

https://reviews.llvm.org/D57566

Files:
  include/llvm/Analysis/LoopInfo.h
  include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
  lib/Analysis/LoopInfo.cpp
  lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
  test/Transforms/LoopVectorize/X86/already-vectorized.ll
  test/Transforms/LoopVectorize/X86/vect.omp.force.small-tc.ll
  test/Transforms/LoopVectorize/remove_metadata.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57566.184679.patch
Type: text/x-patch
Size: 19824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190201/63ff8826/attachment.bin>


More information about the llvm-commits mailing list