[PATCH] D35188: Add bitreverse LNT benchmark.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 5 13:57:23 PDT 2017


hfinkel added inline comments.


================
Comment at: SingleSource/Benchmarks/Misc/revertBits.c:35
+int main (void) {
+  long long sum = 0;
+  for (int i = 0; i < NUM; ++i) {
----------------
Are you sure this doesn't signed overflow? Should we make this unsigned to avoid the possibility of UB.


================
Comment at: SingleSource/Benchmarks/Misc/revertBits.c:37
+  for (int i = 0; i < NUM; ++i) {
+    sum += ReverseBits32(__builtin_bitreverse32(i));
+    sum -= ReverseBits64(__builtin_bitreverse64(i));
----------------
The test suite is used with compilers other than Clang. You should guard this with `__has_builtin` using the pattern detailed here: https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros (it's probably fine for the test to just `exit 0` if we're on a compiler without the builtin)


https://reviews.llvm.org/D35188





More information about the llvm-commits mailing list