[llvm] add power function to APInt (PR #122788)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 12:03:47 PST 2025


================
@@ -29,6 +29,59 @@ TEST(APIntTest, ValueInit) {
   EXPECT_TRUE(!Zero.sext(64));
 }
 
+// Test that 0^5 == 0
+TEST(APIntTest, PowZeroTo5) {
+  APInt Zero = APInt();
+  EXPECT_TRUE(!Zero);
+  APInt ZeroTo5 = APIntOps::pow(Zero, 5);
+  EXPECT_TRUE(!ZeroTo5);
+}
+
+// Test that 1^16 == 1
+TEST(APIntTest, PowOneTo16) {
+  APInt One = APInt::getZero(32) + 1;
----------------
topperc wrote:

Why was this comment resolved but not addressed or responded to?

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


More information about the llvm-commits mailing list