[PATCH] D50530: Added LLVM metadata to generated IR to increase vectorization width

Emmett Neyman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 9 13:21:09 PDT 2018


emmettneyman added inline comments.


================
Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:141
+            << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
+            << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
+            << "}\n";
----------------
morehouse wrote:
> I'm not sure `kArraySize` is what you want here.  Does "width" refer to array size or the SIMD width?
> 
> Any problem with letting the vectorizer determine this automatically?
The "width" refers to how wide the vector types should be in the outputted IR. So for example, a width of 64 would produce IR instructions with the type `<64 x i32>`. 

The problem with letting the vectorizer determine the width automatically is that since the length of the arrays (and so, the number of loop iterations) is passed to the function as a parameter, the vectorizer always chooses the default width of 4 when running the loop vectorize optimization pass.


================
Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:142
+            << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
+            << "}\n";
 }
----------------
morehouse wrote:
> Does this metadata change coverage in the vectorizer?
I'm running the coverage now, but my guess is yes. Because this metadata overrides the default behavior of the loop vectorizer, I think it will increase the coverage.


Repository:
  rC Clang

https://reviews.llvm.org/D50530





More information about the llvm-commits mailing list