From: lkcl Date: Sat, 19 Mar 2022 06:49:11 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c40cd7bd4f5a42684c223c6b6289f392a4dec01;p=nmutil.git --- diff --git a/gfpinv.py b/gfpinv.py index e75773a..45b6dbb 100644 --- a/gfpinv.py +++ b/gfpinv.py @@ -16,12 +16,16 @@ def gfpinv(a): r = 0 s = 1 while v > 0: + # implementations could use count-zeros on + # both u and r to save cycles if u & 1 == 0: u >>= 1 if r & 1 == 0: r >>= 1 else: r = (r + p) >> 1 + # implementations could use count-zeros on + # both v and s to save cycles elif v & 1 == 0: v >>= 1 if s & 1 == 0: