[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#41615: [feature/native-comp] Dump prettier C code.
From: |
Andrea Corallo |
Subject: |
bug#41615: [feature/native-comp] Dump prettier C code. |
Date: |
Mon, 01 Jun 2020 07:19:34 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Nicolas Bértolo <nicolasbertolo@gmail.com> writes:
>> The whole compilation is something like 5x faster here.
> Amazing.I took a closer look at the code that uses casts to bools and
> I think I found a
> bug.
>
> Casting to bool using an enum is equivalent to taking the lowest byte using
> a byte mask. This wrongly casts to "false" integers whose lowest byte is nil.
>
> bool cast_from_unsigned_long_long_to_bool (unsigned long long x)
> {
> return (x & 0xFF);
> }
>
> The correct way to cast to bool is to mimic C semantics:
>
> bool cast_from_unsigned_long_long_to_bool (unsigned long long x)
> {
> if (x != 0)
> return true;
> else
> return false;
> }
>
> Am I right?
>
> Nico.
Okay, now I recall better the whole story.
I believe is okay that emit_coerce can truncate numbers (as regular cast
can do).
Where we have to be careful is into coercing before calling
'emit_cond_jump', again the same attention we use in C when casting
values.
BTW IIRC I've experienced libgccjit crashed on brances with non boolean
tests. At the time I cured that directly in 'emit_cond_jump' performing
a negation on the number to extract the boolean to be used as a test,
this works well.
Andrea
--
akrl@sdf.org
- bug#41615: [feature/native-comp] Dump prettier C code.,
Andrea Corallo <=