[PATCH] D38498: [CodeGen][ExpandMemcmp][NFC] Allow memcmp to expand to vector loads, part 1.

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 00:25:44 PDT 2017


courbet added a comment.

Thanks, My turn to apologize for the delay, I was off for the week-end.



================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:1792-1794
+  while (this->MaxLoadSize > Size) {
+    this->MaxLoadSize /= 2;
+  }
----------------
spatel wrote:
> This used to have log2 rather than a loop, right? I think it's easier to read like this, but I'd keep the comment to explain:
> // Scale the max size down if the target can load more bytes than we need.
Yes, you're right.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:1912-1921
+  IntegerType *const MaxLoadType =
+      NumLoads == 1 ? nullptr
+                    : IntegerType::get(
+                          CI->getContext(),
+                          std::max_element(Entries.begin(), Entries.end(),
+                                           [](const Entry &a, const Entry &b) {
+                                             return a.LoadSize < b.LoadSize;
----------------
spatel wrote:
> That's a tough "line" of code - split up with some local variables to make this more readable.
...and the max_element is actually the same as MaxLoadSize. Thanks for the catch.


https://reviews.llvm.org/D38498





More information about the llvm-commits mailing list