Refix CDIV deoptimization

This commit is contained in:
pancake 2016-06-17 12:37:18 +02:00
parent f96f00d62d
commit 3bbb4d098b

View File

@ -1814,21 +1814,21 @@ static void ds_instruction_mov_lea(RDisasmState *ds, int idx) {
}
static st64 revert_cdiv_magic(st64 magic) {
short s;
st64 E;
const st64 N = ST64_MAX;
st64 candidate;
st64 E, candidate;
short s;
if (llabs (magic) < 0xFFFFFF) {
return 0;
}
if (llabs (magic) > 0xFFFFFFFF) {
if (llabs (magic) > UT32_MAX) {
return 0;
}
if (magic < 0) {
magic += 1L << 31;
magic += 1LL << 32;
}
for (s = 0; s < 16; ++s) {
E = 1L << (32 + s);
for (s = 0; s < 16; s++) {
E = 1LL << (32 + s);
candidate = (E + magic - 1) / magic;
if ( (N * magic) >> (32 + s) == (N / candidate) ) {
return candidate;