[llvm] [ADT] Add implementations for avgFloor and avgCeil to APInt (PR #84431)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 03:09:04 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());
----------------
RKSimon wrote:
(style) Assertions must have messages (same below):
```
assert(C1.getBitWidth() == C2.getBitWidth() && "Unequal bitwidths");
```
https://github.com/llvm/llvm-project/pull/84431
More information about the llvm-commits
mailing list