From e6b700cf9b2a498e2b8f949f798947701b152fae Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 24 Jul 2019 01:37:28 +0000 Subject: [PATCH] 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 --- source/build/include/pragmas.h | 4 ++-- source/build/src/engine.cpp | 4 ++-- source/build/src/pragmas.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index e1eb67b31..5cb1bfb1c 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -58,7 +58,7 @@ skip: 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 int32_t lastd; @@ -88,7 +88,7 @@ skip: extern uint32_t divideu32_noinline(uint32_t n, uint32_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 static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return tabledivide64(ldexp(eax, ecx), ebx); } diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 7bb3b9086..036621b70 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -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)) return -1; - int64_t t = (topt<<16)/bot; + int64_t t = tabledivide64_noinline(topt<<16, bot); *intx = x1 + ((vx*t)>>16); *inty = y1 + ((vy*t)>>16); *intz = z1 + ((vz*t)>>16); - t = (topu<<16)/bot; + t = tabledivide64_noinline(topu<<16, bot); Bassert((unsigned)t < 65536); diff --git a/source/build/src/pragmas.cpp b/source/build/src/pragmas.cpp index 41218c11b..e11a2d7fe 100644 --- a/source/build/src/pragmas.cpp +++ b/source/build/src/pragmas.cpp @@ -24,7 +24,7 @@ void initdivtables(void) 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); } -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