Skip to content

Commit 0e58ea3

Browse files
committed
Put the asymmetric division behind a feature flag
1 parent b03ce24 commit 0e58ea3

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ no-lang-items = []
6060
# Only used in the compiler's build system
6161
rustc-dep-of-std = ['compiler-builtins', 'core']
6262

63+
# Used for faster u128 division on x86_64
64+
asymmetric-asm = []
65+
6366
[[example]]
6467
name = "intrinsics"
6568
required-features = ["compiler-builtins"]

src/int/sdiv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ intrinsics! {
5353
// `_trifecta` is efficient for large divisions, even when division
5454
// hardware is not availiable at all.
5555

56-
#[cfg(not(target = "x86_64"))]
56+
#[cfg(any(not(feature = "asymmetric-asm"), not(target = "x86_64")))]
5757
intrinsics! {
5858
#[win64_128bit_abi_hack]
5959
/// Returns `n / d`
@@ -68,7 +68,7 @@ intrinsics! {
6868
}
6969
}
7070

71-
#[cfg(target = "x86_64")]
71+
#[cfg(all(feature = "asymmetric-asm", target = "x86_64"))]
7272
intrinsics! {
7373
#[win64_128bit_abi_hack]
7474
/// Returns `a / b`

src/int/specialized_div_rem/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod asymmetric;
1818

1919
/// This function is unsafe, because if the quotient of `duo` and `div` does not
2020
/// fit in a `u64`, a floating point exception is thrown.
21-
#[cfg(target = "x86_64")]
21+
#[cfg(all(feature = "asymmetric-asm", target = "x86_64"))]
2222
#[inline]
2323
unsafe fn u128_by_u64_div_rem(duo: u128, div: u64) -> (u64, u64) {
2424
let quo: u64;

src/int/udiv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ intrinsics! {
5656
// `_trifecta` is efficient for large divisions, even when division
5757
// hardware is not availiable at all.
5858

59-
#[cfg(not(target = "x86_64"))]
59+
#[cfg(any(not(feature = "asymmetric-asm"), not(target = "x86_64")))]
6060
intrinsics! {
6161
#[win64_128bit_abi_hack]
6262
/// Returns `n / d`
@@ -81,7 +81,7 @@ intrinsics! {
8181
}
8282
}
8383

84-
#[cfg(target = "x86_64")]
84+
#[cfg(all(feature = "asymmetric-asm", target = "x86_64"))]
8585
intrinsics! {
8686
#[win64_128bit_abi_hack]
8787
/// Returns `n / d`

0 commit comments

Comments
 (0)