------- Comment #17 from etienne_lorrain at yahoo dot fr  2009-02-03 16:38 
-------
(In reply to comment #15)
> The advantage of such a RTL pass (or just adding such optimization to another
> RTL pass) would be that it would handle also say: ...

Why only limit that pass to constants, and only to writes:

etie...@cygne:~$ gcc --version
gcc (Debian 4.3.3-3) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

etie...@cygne:~$ cat tmp.c
struct S
{
  char a;
  char b;
  char c;
  char d;
} u, v;

void fct (void) {
  u.a = v.a;
  u.b = v.b;
  u.c = v.c;
  u.d = v.d;
}

etie...@cygne:~$ gcc -Os -S tmp.c -o tmp.s
etie...@cygne:~$ cat tmp.s
        .file   "tmp.c"
        .text
.globl fct
        .type   fct, @function
fct:
        movb    v, %al
        pushl   %ebp
        movl    %esp, %ebp
        popl    %ebp
        movb    %al, u
        movb    v+1, %al
        movb    %al, u+1
        movb    v+2, %al
        movb    %al, u+2
        movb    v+3, %al
        movb    %al, u+3
        ret
        .size   fct, .-fct
        .comm   u,4,4
        .comm   v,4,4
        .ident  "GCC: (Debian 4.3.3-3) 4.3.3"
        .section        .note.GNU-stack,"",@progbits
etie...@cygne:~$

 A single 32 bits read, and a single 32 bits write should be sufficient,
when none of the fields of the structure is declared volatile.


-- 


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

Reply via email to