]> git.codecow.com Git - nano25519.git/commitdiff
Simplify lanewise doubling.
authorChris Duncan <chris@codecow.com>
Mon, 26 Oct 2026 18:01:23 +0000 (11:01 -0700)
committerChris Duncan <chris@codecow.com>
Mon, 26 Oct 2026 18:01:23 +0000 (11:01 -0700)
src/assembly/ed25519/fep.ts

index b249dfcf408221a376dc1157e3e0851dc78c939c..41c39456bb4caf440e6ac70700f831d21b2187c7 100644 (file)
@@ -314,11 +314,12 @@ export function fep_dbl_lane (h: FieldElementPair, f: FieldElementPair): void {
        const f3 = v128.load(changetype<usize>(f), 3 << 4)
        const f4 = v128.load(changetype<usize>(f), 4 << 4)
 
-       const h0 = v128.bitselect(f0, v128.add<i32>(f0, f0), i32x4(0, -1, 0, -1))
-       const h1 = v128.bitselect(f1, v128.add<i32>(f1, f1), i32x4(0, -1, 0, -1))
-       const h2 = v128.bitselect(f2, v128.add<i32>(f2, f2), i32x4(0, -1, 0, -1))
-       const h3 = v128.bitselect(f3, v128.add<i32>(f3, f3), i32x4(0, -1, 0, -1))
-       const h4 = v128.bitselect(f4, v128.add<i32>(f4, f4), i32x4(0, -1, 0, -1))
+       const m = i64x2(-1, 0)
+       const h0 = v128.add<i32>(f0, v128.and(f0, m))
+       const h1 = v128.add<i32>(f1, v128.and(f1, m))
+       const h2 = v128.add<i32>(f2, v128.and(f2, m))
+       const h3 = v128.add<i32>(f3, v128.and(f3, m))
+       const h4 = v128.add<i32>(f4, v128.and(f4, m))
 
        v128.store(changetype<usize>(h), h0, 0 << 4)
        v128.store(changetype<usize>(h), h1, 1 << 4)