aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-07-05 22:12:22 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2025-07-09 17:12:40 -0700
commitd4cff387764a4e1c2d59e22219fb99f7a03b243f (patch)
treeaef20f04a0798a5e8d88d08110b150937b540a77
parentfactor: speed up umul_ppmm when !USE_LONGLONG_H (diff)
downloadcoreutils-d4cff387764a4e1c2d59e22219fb99f7a03b243f.tar.gz
coreutils-d4cff387764a4e1c2d59e22219fb99f7a03b243f.zip
factor: redo ge2 in terms of lt2
lt2 a bit more natural, given the current implementation. * src/factor.c (lt2): New function. (ge2): Rewrite in terms of lt2. (gt2): Remove. All callers changed to use lt2.
-rw-r--r--src/factor.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/factor.c b/src/factor.c
index 96ef8e828..850e32a59 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -390,24 +390,21 @@ static mp_limb_t __ll_highpart (mp_limb_t t) { return t >> (W_TYPE_SIZE / 2); }
(rl) = (al) << (cnt); \
} while (0)
-/* (ah,hl) >= (bh,bl)? */
+/* (ah,hl) < (bh,bl)? */
static bool
-ge2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
+lt2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
{
mp_limb_t dh, dl;
bool vh = ckd_sub (&dh, ah, bh);
mp_limb_t vl = ckd_sub (&dl, al, bl);
- return ! (vh | ckd_sub (&dh, dh, vl));
+ return vh | ckd_sub (&dh, dh, vl);
}
-/* (ah,hl) > (bh,bl)? */
+/* (ah,hl) >= (bh,bl)? */
static bool
-gt2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
+ge2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
{
- mp_limb_t dh, dl;
- bool vh = ckd_sub (&dh, bh, ah);
- mp_limb_t vl = ckd_sub (&dl, bl, al);
- return vh | ckd_sub (&dh, dh, vl);
+ return !lt2 (ah, al, bh, bl);
}
/* Set (rh,rl) = (ah,al) - (bh,bl). Overflow wraps around. */
@@ -531,7 +528,7 @@ gcd2_odd (mp_limb_t a1, mp_limb_t a0, mp_limb_t b1, mp_limb_t b0)
if ((b1 | a1) == 0)
return make_uuint (0, gcd_odd (b0, a0));
- if (gt2 (a1, a0, b1, b0))
+ if (lt2 (b1, b0, a1, a0))
{
sub_ddmmss (a1, a0, a1, a0, b1, b0);
if (!a0)