[PATCH] D137361: IR: Add atomicrmw uinc_wrap and udec_wrap

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 12:17:35 PST 2022


arsenm added inline comments.


================
Comment at: llvm/docs/LangRef.rst:10471
+-  udec_wrap: ``*ptr = ((*ptr == 0) || (*ptr u> val)) ? val : (*ptr - 1)``
 
 Example:
----------------
JonChesterfield wrote:
> The expressions here look suspicious - I thought these operated as inc/dec then modulo value. Does inc(p,10) really go to zero if p has the initial value 15? If so clamp might be a better name.
> 
> Likewise the ==0 in dec, though I think unsigned compare makes that expression work. Is it *ptr = ((*ptr -1) % val) ?
> 
> 
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#atomicinc

The description here also matches the ISA documentation. I also interpreted this as a clamp, but dec confused me 


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

https://reviews.llvm.org/D137361



More information about the llvm-commits mailing list