Skip to content

Commit

Permalink
fix the wrong index bit of permutation list generation in ntt.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-Wye committed Jan 14, 2025
1 parent 8f4f8e9 commit 536bcb5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/eval/_ntt/ntt.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ void ntt(const int *array, int l, const int *twindle, int p, int *dst) {
: "r"(n));

// prepare the permutation list
for (int k = 0; 2 * k <= l; k++) {
for (int k = 0; 2 * k < l; k++) {
asm("vand.vx v8, v4, %0\n"
"vsub.vv v4, v4, v8\n"
"vsll.vx v8, v8, %1\n" // get the k-th digit and shift left

"vand.vx v12, v4, %2\n"
"vsub.vv v4, v4, v12\n"
"vsrl.vx v12, v12, %1\n" // get the (l-k)-th digit and shift right
"vsrl.vx v12, v12, %1\n" // get the (l-k-1)-th digit and shift right

"vor.vv v4, v4, v8\n"
"vor.vv v4, v4, v12\n"

:
: "r"(1 << k), "r"(l - 1 - 2 * k), "r"(1 << (l - k)));
: "r"(1 << k), "r"(l - 1 - 2 * k), "r"(1 << (l - k - 1)));
}

asm("vsetvli zero, %0, e32, m8, tu, mu\n"
Expand Down

0 comments on commit 536bcb5

Please sign in to comment.