mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-29 04:33:04 +00:00
Add missing tail cost.
This commit is contained in:
parent
6dd89eb0d7
commit
f8e933438e
@ -2547,7 +2547,7 @@ template <bool did_overflow> void ProcessorBase::did_divu(uint32_t dividend, uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(did_overflow) {
|
if(did_overflow) {
|
||||||
dynamic_instruction_length_ = 3; // Just a quick nn n, and then on to prefetch.
|
dynamic_instruction_length_ = 3; // Covers the nn n to get into the loop.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2556,13 +2556,15 @@ template <bool did_overflow> void ProcessorBase::did_divu(uint32_t dividend, uin
|
|||||||
// since this is a classic divide algorithm, but would rather that
|
// since this is a classic divide algorithm, but would rather that
|
||||||
// errors produce incorrect timing only, not incorrect timing plus
|
// errors produce incorrect timing only, not incorrect timing plus
|
||||||
// incorrect results.
|
// incorrect results.
|
||||||
dynamic_instruction_length_ = 3; // Covers the nn n to get into the loop.
|
dynamic_instruction_length_ =
|
||||||
|
3 + // nn n to get into the loop;
|
||||||
|
30 + // nn per iteration of the loop below;
|
||||||
|
3; // n nn upon completion of the loop.
|
||||||
|
|
||||||
divisor <<= 16;
|
divisor <<= 16;
|
||||||
for(int c = 0; c < 15; ++c) {
|
for(int c = 0; c < 15; ++c) {
|
||||||
if(dividend & 0x80000000) {
|
if(dividend & 0x8000'0000) {
|
||||||
dividend = (dividend << 1) - divisor;
|
dividend = (dividend << 1) - divisor;
|
||||||
dynamic_instruction_length_ += 2; // The fixed nn iteration cost.
|
|
||||||
} else {
|
} else {
|
||||||
dividend <<= 1;
|
dividend <<= 1;
|
||||||
|
|
||||||
@ -2570,9 +2572,9 @@ template <bool did_overflow> void ProcessorBase::did_divu(uint32_t dividend, uin
|
|||||||
// and test the sign of the result, but this is easier to follow:
|
// and test the sign of the result, but this is easier to follow:
|
||||||
if (dividend >= divisor) {
|
if (dividend >= divisor) {
|
||||||
dividend -= divisor;
|
dividend -= divisor;
|
||||||
dynamic_instruction_length_ += 3; // i.e. the original nn plus one further n before going down the MSB=0 route.
|
dynamic_instruction_length_ += 1; // i.e. the original nn plus one further n before going down the MSB=0 route.
|
||||||
} else {
|
} else {
|
||||||
dynamic_instruction_length_ += 4; // The costliest path (since in real life it's a subtraction and then a step
|
dynamic_instruction_length_ += 2; // The costliest path (since in real life it's a subtraction and then a step
|
||||||
// back from there) — all costs accrue. So the fixed nn loop plus another n,
|
// back from there) — all costs accrue. So the fixed nn loop plus another n,
|
||||||
// plus another one.
|
// plus another one.
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user