[libc-commits] [PATCH] D137453: [libc] Add add_with_carry to builtin wrapper.
Kirill Okhotnikov via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Nov 4 12:11:37 PDT 2022
orex accepted this revision.
orex added a comment.
This revision is now accepted and ready to land.
Another question to you is how the functions will work with implicit conversion. What I would do is to force input be the same with is_same of enable_if, if they are available.
================
Comment at: libc/src/__support/builtin_wrappers.h:69
+template <typename T>
+inline constexpr T add_with_carry(T a, T b, T carry_in, T &carry_out) {
+ T tmp = a + carry_in;
----------------
Don't you think it will be good to add here static assert, that T is integer and unsigned for this implementation?
================
Comment at: libc/src/__support/builtin_wrappers.h:72
+ T sum = b + tmp;
+ carry_out = (sum < b) | (tmp < a);
+ return sum;
----------------
Nit: From my point of view boolean OR will be more clear, than binary OR.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137453/new/
https://reviews.llvm.org/D137453
More information about the libc-commits
mailing list