File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
intrinsics ! {
2
- // Implementation from gcc
2
+ // Ancient Egyptian/Ethiopian/Russian multiplication method
3
+ // see https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication
4
+ //
5
+ // This is a long-available stock algorithm; e.g. it is documented in
6
+ // Knuth's "The Art of Computer Programming" volume 2 (under the section
7
+ // "Evaluation of Powers") since at least the 2nd edition (1981).
8
+ //
9
+ // The main attraction of this method is that it implements (software)
10
+ // multiplication atop four simple operations: doubling, halving, checking
11
+ // if a value is even/odd, and addition. This is *not* considered to be the
12
+ // fastest multiplication method, but it may be amongst the simplest (and
13
+ // smallest with respect to code size).
14
+ //
15
+ // for reference, see also implementation from gcc
3
16
// https://raw.githubusercontent.com/gcc-mirror/gcc/master/libgcc/config/epiphany/mulsi3.c
17
+ //
18
+ // and from LLVM (in relatively readable RISC-V assembly):
19
+ // https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/riscv/int_mul_impl.inc
4
20
pub extern "C" fn __mulsi3( a: u32 , b: u32 ) -> u32 {
5
21
let ( mut a, mut b) = ( a, b) ;
6
22
let mut r = 0 ;
You can’t perform that action at this time.
0 commit comments