The typo is just one letter 'Z' -> 'X', but a 1-character change is a waste of 
resources so I have beefed up the enclosing comment with a few references.

Tested on x86-64/Linux, applied on the mainline as obvious.


2026-07-16  Eric Botcazou  <[email protected]>

        * expmed.cc (invert_mod2n): Fix typo in comment and add references.

-- 
Eric Botcazou
diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index da1b5b63287..e199129a140 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -3838,9 +3838,9 @@ invert_mod2n (unsigned HOST_WIDE_INT x, int n)
 {
   gcc_assert ((x & 1) == 1);
 
-  /* The algorithm notes that the choice Y = Z satisfies X*Y == 1 mod 2^3,
-     since X is odd.  Then each iteration doubles the number of bits of
-     significance in Y.  */
+  /* The algorithm notes that the choice Y = X satisfies X*Y == 1 mod 2^3,
+     since X is odd.  Then each Newton-Raphson iteration doubles the number
+     of bits of significance in Y (Hensel's lemma).  */
 
   const unsigned HOST_WIDE_INT mask
     = (n == HOST_BITS_PER_WIDE_INT

Reply via email to