Fix vectorizer docs.
authorArnold Schwaighofer <aschwaighofer@apple.com>
Wed, 12 Mar 2014 23:23:44 +0000 (23:23 +0000)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Wed, 12 Mar 2014 23:23:44 +0000 (23:23 +0000)
This example is not vectorized because LLVM does not prove no-wrapping of
"a[i*7] += ...".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203734 91177308-0d34-0410-b5e6-96231b3b80d8

docs/Vectorizers.rst

index 61ebca2bb529f41088385edb1ff310589a71d0a4..823fd9e6702c5081f58d1f1c85b30741c21244a2 100644 (file)
@@ -182,11 +182,14 @@ that scatter/gathers memory.
 
 .. code-block:: c++
 
-  int foo(int *A, int *B, int n, int k) {
-    for (int i = 0; i < n; ++i)
-      A[i*7] += B[i*k];
+  int foo(int * A, int * B, int n) {
+    for (intptr_t i = 0; i < n; ++i)
+        A[i] += B[i*4];
   }
 
+In many situations the cost model will inform LLVM that this is not beneficial
+and LLVM will only vectorize such code if forced with "-mllvm -force-vector-width=#".
+
 Vectorization of Mixed Types
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^