Fix riscv64 compare problem.

Fix 64->32 bits sign/zero extention for riscv64.
This commit is contained in:
herman ten brugge 2020-07-30 09:40:35 +02:00
parent d1ce34448f
commit d55a3f3362
2 changed files with 19 additions and 4 deletions

View File

@ -3605,10 +3605,12 @@ again:
}
ss = ds, ds = 4, dbt = sbt;
} else if (ss == 8) {
/* XXX some architectures (e.g. risc-v) would like it
better for this merely being a 32-to-64 sign or zero-
extension. */
trunc = 32; /* zero upper 32 bits */
/* RISC-V keeps 32bit vals in registers sign-extended.
So here we need a sign-extension for signed types and
zero-extension. for unsigned types. */
#if !defined(TCC_TARGET_RISCV64)
trunc = 32; /* zero upper 32 bits for non RISC-V targets */
#endif
} else {
ss = 4;
}

View File

@ -117,6 +117,18 @@ void tst_builtin(void)
#endif
}
int tst(void)
{
long value = 3;
return -value;
}
void tst_compare(void)
{
/* This failed on risc64 */
if (tst() > 0) printf ("error\n");
}
int
main (void)
{
@ -131,4 +143,5 @@ main (void)
tst_big(big);
tst_adr(&sprintf);
tst_builtin();
tst_compare();
}