epic mul overflow bug
This commit is contained in:
parent
600859ed04
commit
e946e2ab18
@ -225,25 +225,17 @@ macro_rules! uint_overflowing_mul {
|
|||||||
cmpq $$0, %rcx
|
cmpq $$0, %rcx
|
||||||
jne 2f
|
jne 2f
|
||||||
|
|
||||||
mov $8, %rax
|
popcnt $8, %rcx
|
||||||
cmpq $$0, %rax
|
popcnt $7, %rax
|
||||||
setne %cl
|
add %rax, %rcx
|
||||||
|
jrcxz 2f
|
||||||
|
|
||||||
mov $7, %rax
|
popcnt $12, %rcx
|
||||||
cmpq $$0, %rax
|
popcnt $11, %rax
|
||||||
setne %dl
|
add %rax, %rcx
|
||||||
or %dl, %cl
|
jrcxz 2f
|
||||||
|
|
||||||
mov $3, %rax
|
mov $$1, %rcx
|
||||||
cmpq $$0, %rax
|
|
||||||
setne %dl
|
|
||||||
|
|
||||||
mov $2, %rax
|
|
||||||
cmpq $$0, %rax
|
|
||||||
setne %bl
|
|
||||||
or %bl, %dl
|
|
||||||
|
|
||||||
and %dl, %cl
|
|
||||||
|
|
||||||
2:
|
2:
|
||||||
"
|
"
|
||||||
@ -740,7 +732,8 @@ macro_rules! construct_uint {
|
|||||||
type Output = $name;
|
type Output = $name;
|
||||||
|
|
||||||
fn add(self, other: $name) -> $name {
|
fn add(self, other: $name) -> $name {
|
||||||
let (result, _) = self.overflowing_add(other);
|
let (result, overflow) = self.overflowing_add(other);
|
||||||
|
panic_on_overflow!(overflow);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,7 +743,8 @@ macro_rules! construct_uint {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub(self, other: $name) -> $name {
|
fn sub(self, other: $name) -> $name {
|
||||||
let (result, _) = self.overflowing_sub(other);
|
let (result, overflow) = self.overflowing_sub(other);
|
||||||
|
panic_on_overflow!(overflow);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user