[llvm] add power function to APInt (PR #122788)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 09:47:10 PST 2025
================
@@ -3108,3 +3108,22 @@ APInt APIntOps::mulhu(const APInt &C1, const APInt &C2) {
APInt C2Ext = C2.zext(FullWidth);
return (C1Ext * C2Ext).extractBits(C1.getBitWidth(), C1.getBitWidth());
}
+
+APInt APIntOps::pow(const APInt &X, int64_t N) {
+ assert(N >= 0 && "negative exponents not supported.");
+ APInt Acc = APInt(X.getBitWidth(), 1);
+ if (N == 0) {
----------------
topperc wrote:
Drop parentheses on single line body
https://github.com/llvm/llvm-project/pull/122788
More information about the llvm-commits
mailing list