[PATCH] D132960: [InstCombine] Transform small unaligned memcmp calls used in zero equality tests

Martin Sebor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 09:43:16 PDT 2022


msebor added a comment.

> The point here is that these loads are going to be expanded into 16 byte-sized loads by the backend, if the target has strict alignment. See https://llvm.godbolt.org/z/MdqoEEv1P for an example.

The example shows 8 byte loads.  It would be the result of expanding a call to `memcmp(a, b, 8)` with the worst case scenario of both arguments being unaligned.  Without the patch the call is made to the Glibc memcmp.S <https://github.com/lattera/glibc/blob/master/sysdeps/aarch64/memcmp.S>.  I'm not an expert on aarch64 but the inline expansion looks like a clear win to me (except with `-Os` where it might make sense to prefer making the call).  I'd expect the early expansion to be especially helpful when `memcmp` is called more than once with the same unaligned argument because it can then be reused instead of reloaded each time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132960



More information about the llvm-commits mailing list