[llvm] [APInt] Provide isqrt (floor of square root) instead of sqrt (rounded) (PR #197406)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 04:18:42 PDT 2026


================
@@ -1809,8 +1809,8 @@ class [[nodiscard]] APInt {
     return logBase2();
   }
 
-  /// Compute the square root.
-  LLVM_ABI APInt sqrt() const;
+  /// Compute the floor of the square root of the unsigned value.
+  LLVM_ABI APInt isqrt() const;
----------------
jayfoad wrote:

You mean we should keep both versions of the function? I disagree. sqrt-with-rounding should be removed if there are no in-tree users, we shouldn't just keep it on the off chance that someone is using it out-of-tree. And, being slightly opinionated, it's a much less useful function than sqrt-with-floor anyway.

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


More information about the llvm-commits mailing list