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
541 541
542 l = MANT(fl1.l);542 l = MANT(fl1.l);
543 if (exp >= 41)543 if (exp >= 41)
544 return (unsigned long long)-1;544 return (unsigned long long)-1;
545 else if (exp >= 0)545 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;
547 else if (exp >= -23)550 else if (exp >= -23)
548 return l >> -exp;551 if(SIGN(fl1.l))
552 return -(l >> -exp);
553 else
554 return l >> -exp;
549 else555 else
550 return 0;556 return 0;
551}557}
552 558
553long long __fixsfdi (float a1)559long long __fixsfdi (float a1)
@@ -573,13 +579,19 @@ unsigned long long __fixunsdfdi (double a1) · 19 unmodified lines
573 l = MANTD_LL(dl1);579 l = MANTD_LL(dl1);
574 580
575 if (exp >= 12)581 if (exp >= 12)
576 return (unsigned long long)-1;582 return (unsigned long long)-1;
577 else if (exp >= 0)583 else if (exp >= 0)
578 return l << exp;584 if(SIGND(dl1))
585 return -(l >> exp);
586 else
587 return l << exp;
579 else if (exp >= -52)588 else if (exp >= -52)
580 return l >> -exp;589 if(SIGND(dl1))
590 return -(l >> -exp);
591 else
592 return l >> -exp;
581 else593 else
582 return 0;594 return 0;
583}595}
584 596
585long long __fixdfdi (double a1)597long long __fixdfdi (double a1)
@@ -608,7 +620,12 @@ unsigned long long __fixunsxfdi (long double a1) · 22 unmodified lines
608 if (exp > 0)620 if (exp > 0)
609 return (unsigned long long)-1;621 return (unsigned long long)-1;
610 else if (exp >= -63) 622 else if (exp >= -63)
611 return l >> -exp;623 {
624 if(SIGNLD(dl1))
625 return -(l >> -exp);
626 else
627 return l >> -exp;
628 }
612 else629 else
613 return 0;630 return 0;
614}631}
tccgen.c+1−1
@@ -3478,7 +3478,7 @@ again: · 3477 unmodified lines
3478 vtop->c.i = (vtop->c.ld != 0);3478 vtop->c.i = (vtop->c.ld != 0);
3479 } else {3479 } else {
3480 if(sf)3480 if(sf)
3481 vtop->c.i = (int64_t)vtop->c.ld;3481 vtop->c.i = vtop->c.ld;
3482 else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR))3482 else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR))
3483 ;3483 ;
3484 else if (sbt & VT_UNSIGNED)3484 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