[llvm] [mlir] Add cond_sub and sub_clamp operations to atomicrmw (PR #96661)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 03:08:27 PDT 2024


================
@@ -11259,6 +11261,8 @@ operation argument:
 -  fmin: ``*ptr = minnum(*ptr, val)`` (match the `llvm.minnum.*`` intrinsic)
 -  uinc_wrap: ``*ptr = (*ptr u>= val) ? 0 : (*ptr + 1)`` (increment value with wraparound to zero when incremented above input value)
 -  udec_wrap: ``*ptr = ((*ptr == 0) || (*ptr u> val)) ? val : (*ptr - 1)`` (decrement with wraparound to input value when decremented below zero).
+-  cond_sub: ``*ptr = (*ptr u>= val) ? *ptr - val : *ptr`` (subtract only if result would be positive).
+-  sub_clamp: ``*ptr = (*ptr u>= val) ? *ptr - val : 0`` (subtract with clamping of negative results to zero).
----------------
nikic wrote:

And maybe cond_sub should be usub_cond.

https://github.com/llvm/llvm-project/pull/96661


More information about the llvm-commits mailing list