Skip to content

Commit

Permalink
blabla
Browse files Browse the repository at this point in the history
  • Loading branch information
Albin Ahlbäck committed Dec 2, 2024
1 parent 96786cd commit 65fadb4
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 117 deletions.
2 changes: 1 addition & 1 deletion dev/gen_x86_aorsrsh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function aorsrsh(n::Int; is_add::Bool = true)
if !is_add
push( s3)
end
xor( R32(tnc), R32(tnc))
xor( tnc, tnc) # We do not use 32 bit mode here since tnc = %r8.
sub( cnt, tnc) # This is modulo 64, so -n = 64 - n.
xor( R32(sx), R32(sx))

Expand Down
4 changes: 1 addition & 3 deletions src/mpn_extras/aorsrsh_n.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ DECL_AORSRSH(14);
DECL_AORSRSH(15);
DECL_AORSRSH(16);

/* TODO: Should probably rename these types so to not have two different types.
* Probably something like `mpn_binary_h_func`, where `h` is for hardcoded. */
const flint_mpn_aorssh_func_t flint_mpn_addrsh_func_tab[] =
{
NULL,
Expand All @@ -63,7 +61,7 @@ const flint_mpn_aorssh_func_t flint_mpn_addrsh_func_tab[] =
ADDRSH(16)
};

const flint_mpn_aorssh_func_t flint_mpn_subsh_func_tab[] =
const flint_mpn_aorssh_func_t flint_mpn_subrsh_func_tab[] =
{
NULL,
SUBRSH(1),
Expand Down
5 changes: 3 additions & 2 deletions src/mpn_extras/test/t-aors_n.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ TEST_FUNCTION_START(flint_mpn_aors_n, state)
if (!result)
TEST_FUNCTION_FAIL(
"%s:\n"
"aliasing: %d\n"
"aliasing: %s\n"
"ix = %wd\n"
"n = %wd\n"
"xp = %{ulong*}\n"
"yp = %{ulong*}\n"
"FLINT (cy = %wu): %{ulong*}\n"
"GMP (cy = %wu): %{ulong*}\n",
type == 0 ? "flint_mpn_add_n" : "flint_mpn_sub_n",
aliasing, ix, n, xp, n, yp, n, cf, fp, n, cg, gp, n + 1);
aliasing == 0 ? "none" : (aliasing == 1) ? "rp = xp" : "rp = yp",
ix, n, xp, n, yp, n, cf, fp, n, cg, gp, n);

flint_free(fp);
flint_free(gp);
Expand Down
22 changes: 14 additions & 8 deletions src/mpn_extras/test/t-aorsrsh_n.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
#define N_MAX (FLINT_MPN_AORSRSH_FUNC_TAB_WIDTH - 1)
#define N_STOR (FLINT_MPN_AORSRSH_FUNC_TAB_WIDTH + 10)

static mp_limb_t mpn_addrsh_n(mp_ptr rp, mp_srcptr xp, mp_srcptr yp, mp_size_t n, unsigned int cnt)
static
mp_limb_t mpn_addrsh_n(mp_ptr rp, mp_srcptr xp, mp_srcptr yp, mp_size_t n, unsigned int cnt)
{
mpn_rshift(rp, yp, n, cnt);
return mpn_add_n(rp, rp, xp, n);
}

static mp_limb_t mpn_subrsh_n(mp_ptr rp, mp_srcptr xp, mp_srcptr yp, mp_size_t n, unsigned int cnt)
static
mp_limb_t mpn_subrsh_n(mp_ptr rp, mp_srcptr xp, mp_srcptr yp, mp_size_t n, unsigned int cnt)
{
mpn_rshift(rp, yp, n, cnt);
return mpn_sub_n(rp, xp, rp, n);
Expand Down Expand Up @@ -51,7 +53,7 @@ TEST_FUNCTION_START(flint_mpn_aorsrsh_n, state)
/* 0: No aliasing
* 1: fp = xp
* 2: fp = yp */
aliasing = n_randint(state, 3);
aliasing = 0; /* n_randint(state, 3); */

fp = flint_malloc(sizeof(mp_limb_t) * n);
gp = flint_malloc(sizeof(mp_limb_t) * n);
Expand Down Expand Up @@ -101,16 +103,17 @@ TEST_FUNCTION_START(flint_mpn_aorsrsh_n, state)
if (!result)
TEST_FUNCTION_FAIL(
"%s:\n"
"aliasing: %d\n"
"aliasing: %s\n"
"ix = %wd\n"
"n = %u\n"
"cnt = %wd\n"
"n = %wd\n"
"cnt = %u\n"
"xp = %{ulong*}\n"
"yp = %{ulong*}\n"
"FLINT (cy = %wu): %{ulong*}\n"
"GMP (cy = %wu): %{ulong*}\n",
type == 0 ? "flint_mpn_add_n" : "flint_mpn_sub_n",
aliasing, ix, n, cnt, xp, n, yp, n, cf, fp, n, cg, gp, n + 1);
type == 0 ? "flint_mpn_addrsh_n" : "flint_mpn_subrsh_n",
aliasing == 0 ? "none" : (aliasing == 1) ? "rp = xp" : "rp = yp",
ix, n, cnt, xp, n, yp, n, cf, fp, n, cg, gp, n);

flint_free(fp);
flint_free(gp);
Expand All @@ -123,3 +126,6 @@ TEST_FUNCTION_START(flint_mpn_aorsrsh_n, state)
TEST_FUNCTION_END_SKIPPED(state);
#endif
}
#undef N_MIN
#undef N_MAX
#undef N_STOR
Loading

0 comments on commit 65fadb4

Please sign in to comment.