[PATCH] D34885: Add element atomic memset intrinsic

Daniel Neilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 11:18:09 PDT 2017


dneilson added a comment.

In https://reviews.llvm.org/D34885#797072, @efriedma wrote:

> I'm also a little skeptical this is a good idea; the "obvious" intrinsic to provide is one where the size of the value is equal to the atomic element size.  The only reason to prefer this version is to slightly reduce the amount of work required to port existing transforms, and that doesn't seem compelling.


I don't like the idea of having an element atomic memset intrinsic that doesn't follow the semantics of memset -- memset specifically sets every byte of a block of memory to the same value. It does not have super wide usefulness; it's basically just useful for initialization-type stuff like zeroing out blocks of memory. An element atomic version of memset, defined as in this patch, allows us to use memset in IR sourced from, say, Java in the same ways that it would be used in IR sourced from C or Fortran. I don't think that the limited applicability of memset should be a strike against it.

If we want to be able to turn code like "for (int i=0; i<N; i++) a[i] = <some 32-bit integer constant>;" into an intrinsic call that can be optimized & reasoned about, then I think that's a different intrinsic from memset. In fact, it's memset_pattern; but, memset_pattern currently only exists as a libcall in LLVM.

Philip/Eli -- what are your thoughts? Should we try proposing adding memset_pattern as an LLVM intrinsic?


https://reviews.llvm.org/D34885





More information about the llvm-commits mailing list