]> granicus.if.org Git - clang/commitdiff
Added LLVM metadata to generated IR to increase vectorization width
authorEmmett Neyman <eneyman@google.com>
Thu, 9 Aug 2018 21:59:01 +0000 (21:59 +0000)
committerEmmett Neyman <eneyman@google.com>
Thu, 9 Aug 2018 21:59:01 +0000 (21:59 +0000)
Summary: Edited `loop_proto_to_llvm` to emit metadata at the end of the generated IR. This metadata will increase the vector width when the IR is optimized.

Reviewers: morehouse, kcc

Reviewed By: morehouse

Subscribers: cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D50530

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

tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp

index 919b794e1b1f48e377da60548a04c055a22c2fec..4b9abb417068e044da8f7e22c10fa41d19c35762 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "loop_proto_to_llvm.h"
 #include "cxx_loop_proto.pb.h"
+#include "../handle-llvm/input_arrays.h"
 
 // The following is needed to convert protos in human-readable form
 #include <google/protobuf/text_format.h>
@@ -135,7 +136,11 @@ std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
             << x.statements()
             << "%ctnew = add i64 %ct, 1\n"
             << "%j = icmp eq i64 %ctnew, %s\n"
-            << "br i1 %j, label %end, label %loop\n}\n";
+            << "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
+            << "!0 = distinct !{!0, !1, !2}\n"
+            << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
+            << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
+            << "}\n";
 }
 
 // ---------------------------------