[PATCH] D64082: [MemFunctions] Add microbenchmarks for memory functions.

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 3 05:29:31 PDT 2019


courbet added inline comments.


================
Comment at: MicroBenchmarks/MemFunctions/main.cpp:50
+    for (int i = 0; i < kNumElements; ++i) {
+      int res = Pred()(memcmp(p + i * kSize, q + i * kSize, kSize));
+      benchmark::DoNotOptimize(res);
----------------
lebedev.ri wrote:
> I think i'm forgetting about some magic.
> All the predicates (`EqZero`, ...) take a single argument, how does this work if it passes two args?
I think you missed that the **result** of calling memcmp is passed to pred. `Pred` just defines which of `==`, `<` or `>` we're benching. I updated the bench comment to make that clearer.


================
Comment at: MicroBenchmarks/MemFunctions/main.cpp:58-66
+struct EqZero {
+  bool operator()(int v) const { return v == 0; }
+};
+struct LessThanZero {
+  bool operator()(int v) const { return v < 0; }
+};
+struct GreaterThanZero {
----------------
lebedev.ri wrote:
> To be noted, none of these is the actual `memcmp`, i think?
See my comment above.


================
Comment at: MicroBenchmarks/MemFunctions/main.cpp:59
+struct EqZero {
+  bool operator()(int v) const { return v == 0; }
+};
----------------
lebedev.ri wrote:
> Does it matter that these take `int` while you always pass `char`?
See my comment above.


Repository:
  rT test-suite

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64082/new/

https://reviews.llvm.org/D64082





More information about the llvm-commits mailing list