[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

Emmett Neyman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 6 13:06:14 PDT 2018


emmettneyman updated this revision to Diff 159373.
emmettneyman added a comment.

Changed pc to unknown


Repository:
  rC Clang

https://reviews.llvm.org/D50342

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
@@ -43,17 +43,17 @@
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
-    arr = "%a";
+    arr = "%0";
     break;
   case VarRef::ARR_B:
-    arr = "%b";
+    arr = "%1";
     break;
   case VarRef::ARR_C:
-    arr = "%c";
+    arr = "%2";
     break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
-            << "%i = alloca i64\n"
-            << "store i64 0, i64* %i\n"
-            << "br label %loop\n\n"
-            << "loop:\n"
-            << "%ct = load i64, i64* %i\n"
-            << "%comp = icmp eq i64 %ct, %s\n"
-            << "br i1 %comp, label %endloop, label %body\n\n"
-            << "body:\n"
+  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+            << "define void @foo(i32*, i32*, i32*, i64) {\n"
+            << "%5 = icmp sgt i64 %3, 0\n"
+            << "br i1 %5, label %6, label %8\n"
+            << "; <label>:6:\n"
+            << "br label %9\n"
+            << "; <label>:7:\n"
+            << "br label %8\n"
+            << "; <label>:8:\n"
+            << "ret void\n"
+            << "; <label>:9:\n"
+            << " %ct   = phi i64 [ %10, %9 ], [ 0, %6 ]\n"
             << x.statements()
-            << "%z = add i64 1, %ct\n"
-            << "store i64 %z, i64* %i\n"
-            << "br label %loop\n\n"
-            << "endloop:\n"
-            << "ret void\n}\n";
+            << "%10 = add nuw nsw i64 %ct, 1\n"
+            << "%11 = icmp eq i64 %10, %3\n"
+            << "br i1 %11, label %7, label %9\n}\n";
 }
 
 // ---------------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50342.159373.patch
Type: text/x-patch
Size: 2244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180806/6b31ce25/attachment-0001.bin>


More information about the llvm-commits mailing list