[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
Mon Nov 20 20:55:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78821
--- Comment #32 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to rguenther@suse.de from comment #20)
> Index: gcc/tree-ssa-sccvn.c
> ===================================================================
> --- gcc/tree-ssa-sccvn.c (revision 254945)
> +++ gcc/tree-ssa-sccvn.c (working copy)
> @@ -3632,6 +3632,38 @@ visit_nary_op (tree lhs, gassign *stmt)
The patched compiler works for this particular case (a "break" is needed at the
top of the patch, though), but there are many other cases where a temporary
should be calculated and its value stored, e.g.:
--cut here--
void foo_OK (char *buf, unsigned int data)
{
buf[0] = ~data >> 8;
buf[1] = ~data;
}
void foo (char *buf, unsigned int data)
{
buf[0] = ~data;
buf[1] = ~data >> 8;
}
void bar (char *buf, unsigned int data)
{
buf[0] = -data >> 8;
buf[1] = -data;
}
void baz (char *buf, unsigned int data)
{
buf[0] = (data+3) >> 8;
buf[1] = (data+3);
}
--cut here--
Only foo_OK compiles (-O2 -march=haswell) to expected asm:
notl %esi
movbe %si, (%rdi)
all others generate duplicated operation:
movb %sil, %al
notl %esi
notl %eax
movb %al, (%rdi)
movl %esi, %eax
movb %ah, 1(%rdi)
Should I open a new PR for the above enhancement?
More information about the Gcc-bugs
mailing list