[PATCH] D47920: Made loop_proto more "vectorizable"

2018-06-07 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334252: [clang-fuzzer] Made loop_proto more 
"vectorizable". (authored by morehouse, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47920?vs=150435&id=150436#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47920

Files:
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -7,10 +7,13 @@
 //
 //===--===//
 //
-// Implements functions for converting between protobufs and C++. Extends
+// Implements functions for converting between protobufs and C++. Differs from
 // proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
 // loop. Also coutputs a different function signature that includes a
-// size_t parameter for the loop to use.
+// size_t parameter for the loop to use. The C++ code generated is meant to
+// stress the LLVM loop vectorizer.
+//
+// Still a work in progress.
 //
 //===--===//
 
@@ -33,19 +36,7 @@
 std::ostream &operator<<(std::ostream &os, const Const &x) {
   return os << "(" << x.val() << ")";
 }
-std::ostream &operator<<(std::ostream &os, const VarRef &x) {
-  if (x.is_loop_var()) {
-return os << "a[loop_ctr]";
-  } else {
-return os << "a[" << static_cast(x.varnum()) << " % s]";
-  }
-}
-std::ostream &operator<<(std::ostream &os, const Lvalue &x) {
-  return os << x.varref();
-}
 std::ostream &operator<<(std::ostream &os, const Rvalue &x) {
-  if (x.has_varref())
-return os << x.varref();
   if (x.has_cons())
 return os << x.cons();
   if (x.has_binop())
@@ -101,23 +92,18 @@
   return os << x.right() << ")";
 }
 std::ostream &operator<<(std::ostream &os, const AssignmentStatement &x) {
-  return os << x.lvalue() << "=" << x.rvalue();
+  return os << "a[i]=" << x.rvalue();
 }
 std::ostream &operator<<(std::ostream &os, const IfElse &x) {
   return os << "if (" << x.cond() << "){\n"
 << x.if_body() << "} else { \n"
 << x.else_body() << "}\n";
 }
-std::ostream &operator<<(std::ostream &os, const While &x) {
-  return os << "while (" << x.cond() << "){\n" << x.body() << "}\n";
-}
 std::ostream &operator<<(std::ostream &os, const Statement &x) {
   if (x.has_assignment())
 return os << x.assignment() << ";\n";
   if (x.has_ifelse())
 return os << x.ifelse();
-  if (x.has_while_loop())
-return os << x.while_loop();
   return os << "(void)0;\n";
 }
 std::ostream &operator<<(std::ostream &os, const StatementSeq &x) {
@@ -127,7 +113,7 @@
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
   return os << "void foo(int *a, size_t s) {\n"
-<< "for (int loop_ctr = 0; loop_ctr < s; loop_ctr++){\n"
+<< "for (int i=0; i___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47920: Made loop_proto more "vectorizable"

2018-06-07 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.

Looks like a good start.


Repository:
  rC Clang

https://reviews.llvm.org/D47920



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


[PATCH] D47920: Made loop_proto more "vectorizable"

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

Edited loop_proto and its converter to make more "vectorizable" code

- Removed all while loops
- Can only index into array with induction variable


Repository:
  rC Clang

https://reviews.llvm.org/D47920

Files:
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -7,10 +7,13 @@
 //
 //===--===//
 //
-// Implements functions for converting between protobufs and C++. Extends
+// Implements functions for converting between protobufs and C++. Differs from
 // proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
 // loop. Also coutputs a different function signature that includes a
-// size_t parameter for the loop to use.
+// size_t parameter for the loop to use. The C++ code generated is meant to
+// stress the LLVM loop vectorizer.
+//
+// Still a work in progress.
 //
 //===--===//
 
@@ -33,19 +36,7 @@
 std::ostream &operator<<(std::ostream &os, const Const &x) {
   return os << "(" << x.val() << ")";
 }
-std::ostream &operator<<(std::ostream &os, const VarRef &x) {
-  if (x.is_loop_var()) {
-return os << "a[loop_ctr]";
-  } else {
-return os << "a[" << static_cast(x.varnum()) << " % s]";
-  }
-}
-std::ostream &operator<<(std::ostream &os, const Lvalue &x) {
-  return os << x.varref();
-}
 std::ostream &operator<<(std::ostream &os, const Rvalue &x) {
-  if (x.has_varref())
-return os << x.varref();
   if (x.has_cons())
 return os << x.cons();
   if (x.has_binop())
@@ -101,23 +92,18 @@
   return os << x.right() << ")";
 }
 std::ostream &operator<<(std::ostream &os, const AssignmentStatement &x) {
-  return os << x.lvalue() << "=" << x.rvalue();
+  return os << "a[i]=" << x.rvalue();
 }
 std::ostream &operator<<(std::ostream &os, const IfElse &x) {
   return os << "if (" << x.cond() << "){\n"
 << x.if_body() << "} else { \n"
 << x.else_body() << "}\n";
 }
-std::ostream &operator<<(std::ostream &os, const While &x) {
-  return os << "while (" << x.cond() << "){\n" << x.body() << "}\n";
-}
 std::ostream &operator<<(std::ostream &os, const Statement &x) {
   if (x.has_assignment())
 return os << x.assignment() << ";\n";
   if (x.has_ifelse())
 return os << x.ifelse();
-  if (x.has_while_loop())
-return os << x.while_loop();
   return os << "(void)0;\n";
 }
 std::ostream &operator<<(std::ostream &os, const StatementSeq &x) {
@@ -127,7 +113,7 @@
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
   return os << "void foo(int *a, size_t s) {\n"
-<< "for (int loop_ctr = 0; loop_ctr < s; loop_ctr++){\n"
+<< "for (int i=0; i___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits