History

fix float to u64 intrinsics

reverts commit 310e3b428cfd181b51723276e6563b90d670da06 (more info there) now functions check for sign bit in float. now hopefully this patch will cover entirety of areas it might affect

Kyryl Melekhin committed 6 years ago

Commit 618ba551 parent 60c1f702 files · +27 −10Browse files

Unified · Split

2 files
  1. lib/libtcc1.c +26 −9
  2. tccgen.c +1 −1
lib/libtcc1.c+26−9
@@ -541,13 +541,19 @@ unsigned long long __fixunssfdi (float a1) · 540 unmodified lines
541541
542542 l = MANT(fl1.l);
543543 if (exp >= 41)
544− return (unsigned long long)-1;
544+ return (unsigned long long)-1;
545545 else if (exp >= 0)
546− return (unsigned long long)l << exp;
546+ if(SIGN(fl1.l))
547+ return (unsigned long long)-(l << exp);
548+ else
549+ return (unsigned long long)l << exp;
547550 else if (exp >= -23)
548− return l >> -exp;
551+ if(SIGN(fl1.l))
552+ return -(l >> -exp);
553+ else
554+ return l >> -exp;
549555 else
550− return 0;
556+ return 0;
551557 }
552558
553559 long long __fixsfdi (float a1)
@@ -573,13 +579,19 @@ unsigned long long __fixunsdfdi (double a1) · 19 unmodified lines
573579 l = MANTD_LL(dl1);
574580
575581 if (exp >= 12)
576− return (unsigned long long)-1;
582+ return (unsigned long long)-1;
577583 else if (exp >= 0)
578− return l << exp;
584+ if(SIGND(dl1))
585+ return -(l >> exp);
586+ else
587+ return l << exp;
579588 else if (exp >= -52)
580− return l >> -exp;
589+ if(SIGND(dl1))
590+ return -(l >> -exp);
591+ else
592+ return l >> -exp;
581593 else
582− return 0;
594+ return 0;
583595 }
584596
585597 long long __fixdfdi (double a1)
@@ -608,7 +620,12 @@ unsigned long long __fixunsxfdi (long double a1) · 22 unmodified lines
608620 if (exp > 0)
609621 return (unsigned long long)-1;
610622 else if (exp >= -63)
611− return l >> -exp;
623+ {
624+ if(SIGNLD(dl1))
625+ return -(l >> -exp);
626+ else
627+ return l >> -exp;
628+ }
612629 else
613630 return 0;
614631 }
tccgen.c+1−1
@@ -3478,7 +3478,7 @@ again: · 3477 unmodified lines
34783478 vtop->c.i = (vtop->c.ld != 0);
34793479 } else {
34803480 if(sf)
3481− vtop->c.i = (int64_t)vtop->c.ld;
3481+ vtop->c.i = vtop->c.ld;
34823482 else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR))
34833483 ;
34843484 else if (sbt & VT_UNSIGNED)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t