-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding signed cmov #6
Adding signed cmov #6
Conversation
aligned-cmov/src/cmov_impl_asm.rs
Outdated
pub fn cmov_u32(condition: bool, src: &u32, dest: &mut u32) { | ||
fn cmov_numeric<T>(condition: bool, src: &T, dest: &mut T) | ||
where | ||
T: Copy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, this trait bound should be on Cmov
, since Copy
can be (and is) derived for compound types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this function.
So, I can see why you think that making this generic is good, because it will reduce code duplication, which often makes things more maintainable. But, in this case, I'm worried that it is making the code much less maintainable, because there is no type-safety in inline assembly, and using generic parameters makes it very hard for me to reason about what types might be there. So I would much prefer that we undo the |
Removed the generic and using core::mem::transmute instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Motivation
Signed cmov would be useful for some algorithms e.g. Circuit Oram.
In this PR
Refactor unsigned cmov to generic to add signed cmov.
Added signed cmov for i32 and i64
Added test for signed cmov