-
Notifications
You must be signed in to change notification settings - Fork 0
Feature request #2
bacelar edited this page Dec 11, 2021
·
3 revisions
Sometimes, the checks performed at the callee sites by the Jasmin compiler enforcing non-aliasing between input and output reg ptr
arguments are a bit too strict. Specifically, in the following function:
fn _bn_mulm ( reg ptr u64[NLIMBS] a b r ) -> reg ptr u64[NLIMBS] {
stack u64[NLIMBS] tmp;
stack u64[2*NLIMBS] tmp2;
tmp2 = __bn_muln(a, b, tmp2);
r = __bn_rdcn(tmp2, r, tmp);
return r;
}
the compiler rejects a call _bn_mulm(a, b, a)
, but it would in fact be ok -- all the reads from a
occur prior to the write in r
. The workaround would be to write a new version for update in-place:
fn _bn_mulmU ( reg ptr u64[NLIMBS] a b ) -> reg ptr u64[NLIMBS] {
stack u64[NLIMBS] tmp;
stack u64[2*NLIMBS] tmp2;
tmp2 = __bn_muln(a, b, tmp2);
a = __bn_rdcn(tmp2, a, tmp);
return a;
}
It would be nice if we were able to avoid these redundant versions, by relaxing the check.