[llvm] [ADT] Add APIntOps::abds signed absolute difference and rename absdiff -> abdu (PR #84791)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 09:50:26 PDT 2024
================
@@ -2188,8 +2188,13 @@ inline const APInt &umax(const APInt &A, const APInt &B) {
return A.ugt(B) ? A : B;
}
+/// Determine the absolute difference of two APInts considered to be signed.
+inline const APInt abds(const APInt &A, const APInt &B) {
+ return A.sge(B) ? (A - B) : (B - A);
----------------
RKSimon wrote:
Thanks, I always tend towards being overly cautious within ternary
https://github.com/llvm/llvm-project/pull/84791
More information about the llvm-commits
mailing list