[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

Emmett Neyman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 15 11:18:04 PDT 2018


emmettneyman added a comment.

In https://reviews.llvm.org/D50670#1200784, @morehouse wrote:

> Does this hit new coverage in the vectorizer?


Yes, this does hit new coverage in the loop vectorizer code.



================
Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:131
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
-            << "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
-            << "%1 = icmp sgt i64 %s, 0\n"
-            << "br i1 %1, label %start, label %end\n"
-            << "start:\n"
-            << "br label %loop\n"
-            << "end:\n"
-            << "ret void\n"
-            << "loop:\n"
-            << " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
-            << x.statements()
-            << "%ctnew = add i64 %ct, 1\n"
-            << "%j = icmp eq i64 %ctnew, %s\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";
+  os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+     << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
----------------
morehouse wrote:
> Why do you change this to `pc` again?
Sorry, it got changed back when I copy/pasted the IR.


================
Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:136
+     << "outer_loop_start:\n"
+     << "br label %inner_loop_start\n"
+     << "inner_loop_start:\n"
----------------
morehouse wrote:
> Looks like a pointless branch.
I realize it's just a label with a branch instruction but I think I need it for the phi instruction. I will move the `outer_loop_start` label above the `icmp` instruction and change the branch from `outer_loop_start` to `inner_loop_start`.



================
Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:144
+     << x.outer_statements()
+     << "%o_ct_new = add nuw nsw i64 %outer_ct, 1\n"
+     << "%jmp_outer = icmp eq i64 %o_ct_new, %s\n"
----------------
morehouse wrote:
> Why `nuw`, `nsw` here?
Sorry, it got changed back when I copy/pasted the IR.


================
Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:154
+     << "}\n"
+     << "!0 = distinct !{!0, !1, !2}\n"
+     << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
----------------
morehouse wrote:
> Can we simplify the order of blocks here?  It is confusing to follow all these jumps forward and backward.
Yes, I think it might be cleaner to have the blocks like this: 

```
define @foo... {

outer_loop_start

outer_loop

inner_loop_start

inner_loop

end
}
```


Repository:
  rC Clang

https://reviews.llvm.org/D50670





More information about the cfe-commits mailing list