[libc-commits] [PATCH] D82134: [libc] Add strcmp implementation.

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Dec 14 06:59:15 PST 2020


gchatelet added a comment.

In D82134#2451435 <https://reviews.llvm.org/D82134#2451435>, @tschuett wrote:

> The granularity of ARMv8.3 PAC is 16 byte. Can you read an invalid address?

@tschuett I didn't dig into the address granularity, thank you for mentioning it.
Problem here is that we have two pointers to read from so this makes for the following logic:

- both pointers are aligned: we can use 16B loads,
- both pointers are unaligned of the same amount, we can load the first few bytes up to the next 16B boundary and then load 16B at a time,
- pointers have unrelated alignment, not much we can do...

On top of this the return of investment of the "align + load 16B chunks" strategy heavily depends on the size of the two strings - which we can't know in advance since they're 0 terminated.
If on average strings are a few tens of bytes the added complexity will never pay off.

This is different from `memcmp` which provides the size argument that we can use to decide the best strategy in advance.

So it's unclear whether the added complexity will yield any substantial benefit over a simple version that also uses less space in the L1 <https://reviews.llvm.org/L1> instruction cache.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82134



More information about the libc-commits mailing list