Promote divisor argument to tabledivide64 to int64_t and replace a couple of 64-bit divides in rintersect() and inflineintersect()

git-svn-id: https://svn.eduke32.com/eduke32@7820 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/src/build.cpp
This commit is contained in:
terminx 2019-07-24 01:37:28 +00:00 committed by Christoph Oelckers
parent d4a5d94d5b
commit e6b700cf9b
3 changed files with 5 additions and 5 deletions

View file

@ -58,7 +58,7 @@ skip:
return libdivide::libdivide_u32_do(n, &udiv); return libdivide::libdivide_u32_do(n, &udiv);
} }
static inline int64_t tabledivide64(int64_t const n, int32_t const d) static inline int64_t tabledivide64(int64_t const n, int64_t const d)
{ {
static libdivide::libdivide_s64_t sdiv; static libdivide::libdivide_s64_t sdiv;
static int32_t lastd; static int32_t lastd;
@ -88,7 +88,7 @@ skip:
extern uint32_t divideu32_noinline(uint32_t n, uint32_t d); extern uint32_t divideu32_noinline(uint32_t n, uint32_t d);
extern int32_t tabledivide32_noinline(int32_t n, int32_t d); extern int32_t tabledivide32_noinline(int32_t n, int32_t d);
extern int64_t tabledivide64_noinline(int64_t n, int32_t d); extern int64_t tabledivide64_noinline(int64_t n, int64_t d);
#ifdef GEKKO #ifdef GEKKO
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return tabledivide64(ldexp(eax, ecx), ebx); } static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return tabledivide64(ldexp(eax, ecx), ebx); }

View file

@ -7946,12 +7946,12 @@ int32_t rintersect(int32_t x1, int32_t y1, int32_t z1,
else if (bot < 0 && (topt > 0 || topu > 0 || topu <= bot)) else if (bot < 0 && (topt > 0 || topu > 0 || topu <= bot))
return -1; return -1;
int64_t t = (topt<<16)/bot; int64_t t = tabledivide64_noinline(topt<<16, bot);
*intx = x1 + ((vx*t)>>16); *intx = x1 + ((vx*t)>>16);
*inty = y1 + ((vy*t)>>16); *inty = y1 + ((vy*t)>>16);
*intz = z1 + ((vz*t)>>16); *intz = z1 + ((vz*t)>>16);
t = (topu<<16)/bot; t = tabledivide64_noinline(topu<<16, bot);
Bassert((unsigned)t < 65536); Bassert((unsigned)t < 65536);

View file

@ -24,7 +24,7 @@ void initdivtables(void)
uint32_t divideu32_noinline(uint32_t n, uint32_t d) { return divideu32(n, d); } uint32_t divideu32_noinline(uint32_t n, uint32_t d) { return divideu32(n, d); }
int32_t tabledivide32_noinline(int32_t n, int32_t d) { return tabledivide32(n, d); } int32_t tabledivide32_noinline(int32_t n, int32_t d) { return tabledivide32(n, d); }
int64_t tabledivide64_noinline(int64_t n, int32_t d) { return tabledivide64(n, d); } int64_t tabledivide64_noinline(int64_t n, int64_t d) { return tabledivide64(n, d); }
#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // NOASM #if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // NOASM