mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Use own implementation of pow_int_ instead of llvm
Remove LLVM intrinsics code related to `Num.powInt`.
This commit is contained in:
parent
2404882c1a
commit
e89af31015
4 changed files with 45 additions and 8 deletions
|
@ -10,3 +10,25 @@
|
|||
pub fn i64_to_f64_(num: i64) -> f64 {
|
||||
num as f64
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn pow_int_(mut base: i64, mut exp: i64) -> i64 {
|
||||
let mut acc = 1;
|
||||
|
||||
while exp > 1 {
|
||||
if (exp & 1) == 1 {
|
||||
acc *= base;
|
||||
}
|
||||
exp /= 2;
|
||||
base *= base;
|
||||
}
|
||||
|
||||
// Deal with the final bit of the exponent separately, since
|
||||
// squaring the base afterwards is not necessary and may cause a
|
||||
// needless overflow.
|
||||
if exp == 1 {
|
||||
acc *= base;
|
||||
}
|
||||
|
||||
acc
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue