[Bug tree-optimization/78821] GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 9 15:35:00 GMT 2017


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

--- Comment #13 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #12)

> --cut here--
> struct s { char a; char b; char c; char d; };
> 
> void foo (struct s *__restrict a, struct s *__restrict b)
> {
>   a->a = b->a;
>   a->b = b->b;
>   a->c = ~b->c;
>   a->d = b->d;
> }
> --cut here--
> 
> This testcase can be optimized by inserting xorl mask between load and
> store, as suggested above.

Also,

a->a = 0;
a->b = 0;
a->c = b->c;
a->d = 0;

could use andl mask, and similar

a->a = 0xff;
a->b = 0xff;
a->c = b->c;
a->d = 0xff;

could use orl mask.


More information about the Gcc-bugs mailing list