Skip to content

Commit

Permalink
make blas_quickdivide unsigned and guard against miscompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-frbg authored Jun 5, 2020
1 parent 0f9a935 commit 0464e66
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions common_x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void __inline blas_lock(volatile BLASULONG *address){
#endif

do {
while (*address) {YIELDING;};
while (*address) {YIELDING;}

#ifndef C_MSVC
__asm__ __volatile__(
Expand Down Expand Up @@ -199,9 +199,9 @@ static __inline BLASLONG blas_quickdivide(BLASLONG x, BLASLONG y){
#else
extern unsigned int blas_quick_divide_table[];

static __inline int blas_quickdivide(unsigned int x, unsigned int y){
static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){

unsigned int result;
volatile unsigned int result;

if (y <= 1) return x;

Expand All @@ -215,7 +215,6 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
y = blas_quick_divide_table[y];

__asm__ __volatile__ ("mull %0" :"=d" (result), "+a"(x) : "0" (y));

return result;
}
#endif
Expand Down

0 comments on commit 0464e66

Please sign in to comment.