[Bug middle-end/68360] GCC bitfield processing code is very inefficient
ebotcazou at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 18 18:00:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68360
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu.org
--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Here's another example where GCC generates suboptimal code for bitfield
> initialization on x64: https://godbolt.org/g/WeqAr5.
Again the code is better for example on SPARC:
sll %o1, 30, %o1
sethi %hi(-1073741824), %g1
andn %o2, %g1, %o2
or %o1, %o2, %o1
jmp %o7+8
st %o1, [%o0]
It is very bad on x86 because, when get_best_mode is invoked as such:
get_best_mode (bitsize=2, bitpos=0, bitregion_start=0, bitregion_end=31,
align=32, largest_mode=SImode, volatilep=false)
at /home/eric/svn/gcc/gcc/stor-layout.c:2800
it returns QImode. If it returned SImode as on SPARC, the code would be:
sall $2, %edx
andl $3, %esi
orl %edx, %esi
movl %esi, (%rdi)
ret
More information about the Gcc-bugs
mailing list