===================
Usage
-^^^^^^
+-----
LLVM's Loop Vectorizer is now available and will be useful for many people.
It is not enabled by default, but can be enabled through clang using the
We plan to enable the Loop Vectorizer by default as part of the LLVM 3.3 release.
Features
-^^^^^^^^^
+--------
The LLVM Loop Vectorizer has a number of features that allow it to vectorize
complex loops.
Loops with unknown trip count
-------------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Loop Vectorizer supports loops with an unknown trip count.
In the loop below, the iteration ``start`` and ``finish`` points are unknown,
}
Runtime Checks of Pointers
---------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^^
In the example below, if the pointers A and B point to consecutive addresses,
then it is illegal to vectorize the code because some elements of A will be
Reductions
---------------------------
+^^^^^^^^^^
In this example the ``sum`` variable is used by consecutive iterations of
the loop. Normally, this would prevent vectorization, but the vectorizer can
}
Inductions
---------------------------
+^^^^^^^^^^
In this example the value of the induction variable ``i`` is saved into an
array. The Loop Vectorizer knows to vectorize induction variables.
}
If Conversion
---------------------------
+^^^^^^^^^^^^^
The Loop Vectorizer is able to "flatten" the IF statement in the code and
generate a single stream of instructions. The Loop Vectorizer supports any
}
Pointer Induction Variables
----------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
This example uses the "accumulate" function of the standard c++ library. This
loop uses C++ iterators, which are pointers, and not integer indices.
}
Reverse Iterators
---------------------------
+^^^^^^^^^^^^^^^^^
The Loop Vectorizer can vectorize loops that count backwards.
}
Scatter / Gather
-----------------
+^^^^^^^^^^^^^^^^
The Loop Vectorizer can vectorize code that becomes scatter/gather
memory accesses.
}
Vectorization of Mixed Types
-----------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Loop Vectorizer can vectorize programs with mixed types. The Vectorizer
cost model can estimate the cost of the type conversion and decide if
}
Vectorization of function calls
--------------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Loop Vectorize can vectorize intrinsic math functions.
See the table below for a list of these functions.
+-----+-----+---------+
Performance
-^^^^^^^^^^^
+-----------
This section shows the the execution time of Clang on a simple benchmark:
`gcc-loops <http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vectorizer/>`_.
==========================
Usage
-^^^^^^
+------
The Basic Block Vectorizer is not enabled by default, but it can be enabled
through clang using the command line flag:
$ clang -fslp-vectorize file.c
Details
-^^^^^^^
+-------
The goal of basic-block vectorization (a.k.a. superword-level parallelism) is
to combine similar independent instructions within simple control-flow regions