[libc-commits] [PATCH] D126768: [libc][mem*] Introduce Sized/Backends for new mem framework

Clement Courbet via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 1 05:12:50 PDT 2022


courbet added a comment.

As a very high level, design comment, I would like to note that I think we should strive to get into a state where the lowering of a `SizedOp` is done via a instrinsic call for all operation type (right now, this is only the case for `memcpy`).

The idea is that there are currently two places where we know how to lower a memory operation: the `Backend`, and the compiler (through the `__builtin_memxxx_inline`). In the future, any improvement to the `Backend` will only impact the codegen for `memxxx`, but not the expansion of a `memxxx(p, q, constant_size)`. One way to ensure non-divergence between the `Backend` implementations and the builtins is to actually use the builtins for lowering (at least in the "normal", non-temporal case).

So eventually, all implementations should look like the one for `copy`:

   if constexpr (LLVM_LIBC_USE_BUILTIN_MEMXXX_INLINE && /*is normal*/) {
       // delegate optimized operation to compiler.
       __builtin_memxxx_inline(dst.ptr(), src.ptr(), Size);
       return;
     }
     // Fancy c++ implementation.
  }

This is especially true for `memcmp` (I'm not sure how much love the `ExpandMemcmp` pass has had wrt aarch64), and `memset` (for example, `__builtin_memset` does not currently know to use `zva`: https://godbolt.org/z/6noee3Y6c).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126768



More information about the libc-commits mailing list