[llvm] [KnownBits] Add KnownBits::absdiff to compute the absolute difference of 2 unsigned values (PR #82354)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 08:29:04 PST 2024


================
@@ -281,7 +281,14 @@ TEST(KnownBitsTest, BinaryExhaustive) {
         return KnownBits::smin(Known1, Known2);
       },
       [](const APInt &N1, const APInt &N2) { return APIntOps::smin(N1, N2); });
-
+  testBinaryOpExhaustive(
+      [](const KnownBits &Known1, const KnownBits &Known2) {
+        return KnownBits::absdiff(Known1, Known2);
+      },
+      [](const APInt &N1, const APInt &N2) {
+        return APIntOps::absdiff(N1, N2);
+      },
+      checkCorrectnessOnlyBinary);
----------------
nikic wrote:

Can you please also add some non-exhaustive tests to demonstrate that both of your absdiff implementations are necessary (i.e. if you remove either one, something should fail)?

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


More information about the llvm-commits mailing list