https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102285

--- Comment #28 from qinzhao at gcc dot gnu.org ---
(In reply to Richard Biener from comment #21)
> Reduced testcase:
> 
> int
> qy (void)
> {
>   int tw = 4;
>   int fb[tw];
>   return fb[2];
> }

For this reduced testing case, if compiled with 
/home/opc/Install/latest/bin/gcc -c -O -ftrivial-auto-var-init=zero
-fdump-tree-all t.c

******t.c.032t.cpp1:
int qy (int l9)
{
  unsigned char fb.3[16];
  int tw;
  int[0:D.1984] * fb.1;
  sizetype D.1984;
  void * saved_stack.2_16;
  int _27;

  <bb 2> :
  saved_stack.2_16 = __builtin_stack_save ();
  fb.1_25 = &fb.3;
  (*fb.1_25) = .DEFERRED_INIT (16, 2, 1);
  _27 = (*fb.1_25)[2];
  ..
}

******t.c.033t.forwprop1:
int qy (int l9)
{
  unsigned char fb.3[16];
  int tw;
  int[0:D.1984] * fb.1;
  sizetype D.1984;
  void * saved_stack.2_16;
  int _27;

  <bb 2> :
  saved_stack.2_16 = __builtin_stack_save ();
  MEM[(int[0:D.1984] *)&fb.3] = .DEFERRED_INIT (16, 2, 1);
  _27 = MEM[(int[0:D.1984] *)&fb.3][2];
  ..
}

the problem with the above IR for .DEFERRED_INIT expansion is:

for MEM[(int[0:D.1984] *)&fb.3] = .DEFERRED_INIT (16, 2, 1);

after the "ccp" and "forwprop", the original VLA *fb.1 is replaced with the the
new fixed array &fb.3, however, the VAR_TYPE still is the old VLA type
int[0:D.1984]. if we can replace the var_type to the new "unsigned char [16]"
for both the LHS and the call to .DEFERRED_INIT. then expansion through
assign_expand should work.

We might need to special handling the LHS to get the new type for "fb.3"
instead of the old "var_type" for "assign_expand".

Reply via email to