public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Why can't copy renaming capture this assignment?
@ 2012-03-31  4:22 Jiangning Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Jiangning Liu @ 2012-03-31  4:22 UTC (permalink / raw)
  To: gcc

Hi,

For this small case, 

char garr[100];
void f(void)
{
        unsigned short h, s;

        s = 20;

        for (h = 1; h < (s-1); h++)
        {
                garr[h] = 0;
        }
}

After copyrename3, we have the following dump,

f ()
{
  short unsigned int h;
  int D.4066;

<bb 2>:
  D.4066_14 = 1;
  if (D.4066_14 <= 18)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  # h_15 = PHI <h_8(3), 1(2)>
  # D.4066_16 = PHI <D.4066_4(3), D.4066_14(2)>
  garr[D.4066_16] = 0;
  h_8 = h_15 + 1;
  D.4066_4 = (int) h_8;
  if (D.4066_4 <= 18)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 4>:
  return;

}

copy renaming fails to capture the assignment statement "D.4066_4 = (int)
h_8;" to trigger renaming partition coalesce. 

I find gimple_assign_single_p invoked by gimple_assign_ssa_name_copy_p
always returns false, because for this statement " gs->gsbase.subcode" is
NOP_EXPR rather than GIMPLE_SINGLE_RHS.

Should subcode be correctly initialized anywhere to fix this problem?

BTW, my expectation after copy renaming is like below, 

f ()
{
  int D.4679;

<bb 2>:
  D.4679_7 = 1;
  if (D.4679_7 != 19)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  # D.4679_15 = PHI <D.4679_4(3), D.4679_7(2)>
  # D.4679_17 = PHI <D.4679_14(3), 1(2)>
  garr[D.4679_15] = 0;
  D.4679_14 = D.4679_17 + 1;
  D.4679_4 = D.4679_14;
  if (D.4679_4 != 19)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 4>:
  return;

}

and then PRE can finally remove that redundancy for symbol D.xxxx away.

Thanks,
-Jiangning





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-04  8:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4f7686a1.6548b60a.5636.2b32SMTPIN_ADDED@mx.google.com>
2012-04-02  8:37 ` Why can't copy renaming capture this assignment? Richard Guenther
     [not found]   ` <CAOQ849PLycvKE4p7xkB-Teu-MN-5pjpWFMqOCb4xrUt-q8CTRA@mail.gmail.com>
2012-04-03  8:51     ` Richard Guenther
     [not found]       ` <CAOQ849Pio87BYadK9MV49GwuXtrQsdWKynCFJQoSHcaEozS0ig@mail.gmail.com>
2012-04-04  8:49         ` Richard Guenther
2012-03-31  4:22 Jiangning Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).