[PATCH] Add #pragma vectorize enable/disable to LLVM

Renato Golin renato.golin at linaro.org
Wed Dec 4 08:21:32 PST 2013


Hi nadav,

The intended behaviour is to force vectorization on the presence
of the flag (either turn on or off), and to continue the behaviour
as expected in its absence. Tests were added to make sure the all
cases are covered in opt. No tests were added in other tools with
the assumption that they should use the PassManagerBuilder in the
same way.

The pragma metadata is being attached to the same place as other loop
metadata, but nothing forbids one from attaching it to a function
(to enable #pragma optimize) or basic blocks (to hint the basic-block
vectorizers), etc. The logic should be the same all around.

Patches to Clang to produce the metadata will be produced after the
initial implementation is agreed upon and committed. Patches to other
vectorizers (such as SLP and BB) will be added once we're happy with
the pass manager changes.

Semantics of the flags:

1. #pragma vectorize enable/disable always wins, regardless of flags
2. -disable-loop-vectorizer in opt will disable (only vectorizing pragmas)
3. -llop-vectorize / -vectorize-loops / -fvectorize (in Clang) will turn it on on all opt levels
4. -O2+ and -Os will turn it on by default

We may want 2 to override 1, I'm not sure yet.

Semantics of the pass manager:

* We're now always adding the vectorizer pass with a flag if it has to check or not for pragmas
* The default is to not check, since opt can be created with the pass via -loop-vectorize, which doesn't pass through AddOptimizationPasses()
* Clean-up passes are being passed (and ran), even if the vectorizer doesn't vectorize anything, which increases slightly the compilation time (~2% on some tests I did here at O1), which is not ideal (ideas welcome!)
* The main issue is that I DO want to run them if there was a pragma enable, but this is rare, so would be better to have an alternative solution.


http://llvm-reviews.chandlerc.com/D2328

Files:
  include/llvm/Transforms/Vectorize.h
  lib/Transforms/IPO/PassManagerBuilder.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/metadata-enable.ll
  tools/opt/opt.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2328.1.patch
Type: text/x-patch
Size: 12665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131204/ead86d36/attachment.bin>


More information about the llvm-commits mailing list