In fact it was related to unsigned __int64 not signed __int64
The following patch modeled after TOK_DIV in x86_64-gen fixes, at least for
my case, this issue.
Could you please review the patch?
} else {
if (op == TOK_UDIV || op == TOK_UMOD) {
#if 1
if ((vtop->type.t & VT_BTYPE) & VT_LLONG) {
o(0x9948); /* cqto */
o(0x48 + REX_BASE(fr));
} else {
o(0x99); /* cltd */
}
o(0xf7); /* idiv fr, %eax */
o(0xf0 + fr);
#else
o(0xf7d231); /* xor %edx, %edx, div fr, %eax */
o(0xf0 + fr);
#endif
Christian
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Christian Jullien
Sent: vendredi 18 décembre 2009 12:18
To: [email protected]
Subject: [Tinycc-devel] Wrong __int64 computation
Here is a simple test case that shows the bug:
#include <stdio.h>
int
main()
{
int i = 16;
__int64 j = 16;
unsigned __int64 n;
// Use %p to show all bits
n = 0x7fffffffffff;
printf("Init: n=%p, sizeof(n) = %d\n", n, sizeof(n)); // == 8 Ok!
n = 0x7fffffffffff;
n = n / i; // i is an int
printf("Wrong: n=%p\n", n);
n = 0x7fffffffffff;
n = n / j; // j is an __int64
printf("Wrong: n=%p\n", n);
n = 0x7fffffffffff;
n = n / 16;
printf("Good: n=%p\n", n);
}
_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel
----------------------------------------------------------------------------
-----------
Orange vous informe que cet e-mail a ete controle par l'anti-virus mail.
Aucun virus connu a ce jour par nos services n'a ete detecte.
_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel