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

2018-08-09 Thread Emmett Neyman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339392: Added LLVM metadata to generated IR to increase 
vectorization width (authored by emmettneyman, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50530?vs=160016=160017#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50530

Files:
  cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp


Index: cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -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 
@@ -135,7 +136,11 @@
 << 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";
 }
 
 // -


Index: cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -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 
@@ -135,7 +136,11 @@
 << 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";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-08-09 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 160016.
emmettneyman added a comment.

Rebased and ready to land


Repository:
  rC Clang

https://reviews.llvm.org/D50530

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


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -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 
@@ -135,7 +136,11 @@
 << 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";
 }
 
 // -


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -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 
@@ -135,7 +136,11 @@
 << 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";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-08-09 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.
This revision is now accepted and ready to land.

Code LGTM, but let's make sure this actually helps before landing.


Repository:
  rC Clang

https://reviews.llvm.org/D50530



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-08-09 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 159993.
emmettneyman added a comment.

Switched the include statement to the cpp file


Repository:
  rC Clang

https://reviews.llvm.org/D50530

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


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -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 
@@ -135,7 +136,11 @@
 << 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";
 }
 
 // -


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -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 
@@ -135,7 +136,11 @@
 << 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";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-08-09 Thread Emmett Neyman via Phabricator via cfe-commits
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



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-08-09 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse 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";

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?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:142
+<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
+<< "}\n";
 }

Does this metadata change coverage in the vectorizer?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h:18
 
+#include "../handle-llvm/input_arrays.h"
+

This include should be in the cpp file.


Repository:
  rC Clang

https://reviews.llvm.org/D50530



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-08-09 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman created this revision.
emmettneyman added reviewers: morehouse, kcc.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D50530

Files:
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
@@ -15,6 +15,8 @@
 #include 
 #include 
 
+#include "../handle-llvm/input_arrays.h"
+
 namespace clang_fuzzer {
 class LoopFunction;
 
Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -135,7 +135,11 @@
 << 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";
 }
 
 // -


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
@@ -15,6 +15,8 @@
 #include 
 #include 
 
+#include "../handle-llvm/input_arrays.h"
+
 namespace clang_fuzzer {
 class LoopFunction;
 
Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -135,7 +135,11 @@
 << 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";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits