------- Comment #10 from rguenth at gcc dot gnu dot org  2008-03-14 20:06 
-------
This is related to PR27799.  It is also fixed with -fstrict-aliasing on the
tree level:

bar ()
{
  struct example * ex1.0;

<bb 2>:
  ex1.0 = ex1;
  ex1.0->a = 1;
  ex1.0->b = 2;
  ex1.0->c = 3;
  return;

}

Without -fstrict-aliasing we get (see PR27799):

bar ()
{
  struct example * ex1.0;

<bb 2>:
  # VUSE <ex1_4(D)>
  ex1.0_1 = ex1;
  # ex1_6 = VDEF <ex1_4(D)>
  # SMT.5_7 = VDEF <SMT.5_5(D)>
  ex1.0_1->a = 1;
  # VUSE <ex1_6>
  ex1.0_2 = ex1;
  # ex1_8 = VDEF <ex1_6>
  # SMT.5_9 = VDEF <SMT.5_7>
  ex1.0_2->b = 2;
  # VUSE <ex1_8>
  ex1.0_3 = ex1;
  # ex1_10 = VDEF <ex1_8>
  # SMT.5_11 = VDEF <SMT.5_9>
  ex1.0_3->c = 3;
  return;

while with -fstrict-aliasing we have

bar ()
{
  struct example * ex1.0;

<bb 2>:
  # VUSE <ex1_4(D)>
  ex1.0_1 = ex1;
  # SMT.5_6 = VDEF <SMT.5_5(D)>
  ex1.0_1->a = 1;
  # VUSE <ex1_4(D)>
  ex1.0_2 = ex1;
  # SMT.5_7 = VDEF <SMT.5_6>
  ex1.0_2->b = 2;
  # VUSE <ex1_4(D)>
  ex1.0_3 = ex1;
  # SMT.5_8 = VDEF <SMT.5_7>
  ex1.0_3->c = 3;
  return;

}

If you disable all tree optimizations that do the optimization you still
have the missed optimization on the RTL level and get

bar:
        pushl   %ebp
        movl    %esp, %ebp
        movl    ex1, %eax
        movb    $1, (%eax)
        movl    ex1, %eax
        movl    $2, 4(%eax)
        movb    $3, 8(%eax)
        popl    %ebp
        ret

without strict-aliasing it gets even

bar:
        pushl   %ebp
        movl    %esp, %ebp
        movl    ex1, %eax
        movb    $1, (%eax)
        movl    ex1, %eax
        movl    $2, 4(%eax)
        movl    ex1, %eax
        movb    $3, 8(%eax)
        popl    %ebp
        ret


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
OtherBugsDependingO|                            |27799
              nThis|                            |
   Last reconfirmed|2006-02-16 21:27:01         |2008-03-14 20:06:36
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=2480

Reply via email to