[llvm] [llvm] Add KnownBits implementations for avgFloor and avgCeil (PR #86445)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 09:02:14 PDT 2024


================
@@ -559,6 +559,42 @@ TEST(KnownBitsTest, BinaryExhaustive) {
       KnownBits::mulhu,
       [](const APInt &N1, const APInt &N2) { return APIntOps::mulhu(N1, N2); },
       checkCorrectnessOnlyBinary);
+
+  testBinaryOpExhaustive(
+      [](const KnownBits &Known1, const KnownBits &Known2) {
+        return KnownBits::avgFloorS(Known1, Known2);
+      },
+      [](const APInt &N1, const APInt &N2) {
+        return APIntOps::avgFloorS(N1, N2);
+      },
+      checkCorrectnessOnlyBinary);
----------------
jayfoad wrote:

I think you could probably make the KnownBits implementation optimal by using the ext/add/shift/trunc method.

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


More information about the llvm-commits mailing list