https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117885
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Schrodinger ZHU Yifan from comment #2)
> (In reply to Richard Biener from comment #1)
> > The 'GIMPLE' doesn't look like GIMPLE.
>
> The GIMPLE is the unmodified GIMPLE obtained from GCCJIT’s
> dump_initial_gimple option. The variable name such %x are just named using
> unmangled special character direction from upper level language.
>
> > What is bitcast()?
>
> It is obtained via gcc_jit_context_new_bitcast API.
I see.
> > Can you show the
> > -fdump-tree-X-gimple output with 'X' being the point after GIMPLE
> > generation?
>
> Not sure I can pass that as a driver argument or not but I can try playing
> with it and also other gimple dumping options provided by gccjit.
It looks like the dump_initial_gimple doesn't dump GIMPLE as "replayed",
but some internal JIT IL? I see playback::context::new_bitcast will
turn it into a VIEW_CONVERT_EXPR. It's also not clear what in the JITs
IL is a register and what an aggregate.
In particular
%5 = %4.A:17;
%6 = %4.B:5;
%7 = %4.C:10;
%8 = %5 == %1;
on GIMPLE you'd have %5 a int:17 but %1 is int, so the comparison would
compare two incompatible things. That means
%5 = gccjit.access_field %4[0] : !bitfields -> !int
is possibly wrong on your side and you'd need a promotion to int unless
the JIT does C promotion rules here?
The C program
struct Int
{
int A:17;
int B:5;
int C:10;
};
void foo (int arg0, int arg1, int arg2, int arg3)
{
struct Int I;
I = *(struct Int *)&arg0;
if (I.A == arg1 && I.B == arg2 && I.C == arg3)
return;
__builtin_trap ();
}
is compiled to GIMPLE
__BB(2):
_1 = &arg0;
I = __MEM <struct Int> ((struct Int *)_1);
_2 = I.A;
_3 = (int) _2;
if (arg1 == _3)
goto __BB3;
else
goto __BB6;
__BB(3):
_4 = I.B;
_5 = (int) _4;
if (arg2 == _5)
goto __BB4;
else
goto __BB6;
__BB(4):
_6 = I.C;
_7 = (int) _6;
if (arg3 == _7)
goto __BB5;
else
goto __BB6;
__BB(5):
// predicted unlikely by early return (on trees) predictor.
I = _Literal (struct Int) {CLOBBER(eos)};
return;