riscv64: Fix a corner case

found in mpfr.  Expressions like "(longlong)i <= MAX_ULONGLONG" are
always true (not yet short-circuited in tcc), but still need to be
handled correctly in the backends.
This commit is contained in:
Michael Matz 2020-07-15 21:47:39 +02:00
parent 92769362c7
commit a614269794
2 changed files with 11 additions and 1 deletions

View File

@ -999,7 +999,7 @@ static void gen_opil(int op, int ll)
++fc; ++fc;
case TOK_LT: func3 = 2; goto do_cop; // slti d, a, fc case TOK_LT: func3 = 2; goto do_cop; // slti d, a, fc
case TOK_ULE: case TOK_ULE:
if (fc >= (1 << 11) - 1) if (fc >= (1 << 11) - 1 || fc == -1)
break; break;
++fc; ++fc;
case TOK_ULT: func3 = 3; goto do_cop; // sltiu d, a, fc case TOK_ULT: func3 = 3; goto do_cop; // sltiu d, a, fc

View File

@ -463,6 +463,15 @@ void if2t(void)
printf("if2t:ok3\n"); printf("if2t:ok3\n");
} }
void if3t(void)
{
volatile long long i = 1;
if (i <= 18446744073709551615ULL)
;
else
printf ("if3t:wrong 1\n");
}
void if_test(void) void if_test(void)
{ {
if1t(1, 0, 0, 0); if1t(1, 0, 0, 0);
@ -470,6 +479,7 @@ void if_test(void)
if1t(3, 2, 0, 0); if1t(3, 2, 0, 0);
if1t(4, 2, 3, 0); if1t(4, 2, 3, 0);
if2t(); if2t();
if3t();
} }
void loop_test() void loop_test()