[llvm] [ADT] Add implementations for avgFloor and avgCeil to APInt (PR #84431)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 03:13:50 PDT 2024


================
@@ -3094,3 +3094,39 @@ void llvm::LoadIntFromMemory(APInt &IntVal, const uint8_t *Src,
     memcpy(Dst + sizeof(uint64_t) - LoadBytes, Src, LoadBytes);
   }
 }
+
+APInt APIntOps::avgFloorS(const APInt &C1, const APInt &C2) {
+  // Return floor((C1 + C2)/2)
+  assert(C1.getBitWidth() == C2.getBitWidth());
----------------
jayfoad wrote:

I know that's what the coding standards say, but it seems a bit silly when it encourages people to write a message that just says exactly the same as the condition, but in English.

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


More information about the llvm-commits mailing list