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

Roman Perepelitsa <roman.perepelitsa at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roman.perepelitsa at gmail dot 
com

--- Comment #3 from Roman Perepelitsa <roman.perepelitsa at gmail dot com> ---
Here's another example where GCC generates suboptimal code for bitfield
initialization on x64: https://godbolt.org/g/WeqAr5.

  #include <stdint.h>

  struct S {
    S(uint32_t a, uint32_t b);

    uint32_t a : 2;
    uint32_t b : 30;
  };

  S::S(uint32_t a, uint32_t b) : a(a), b(b) {}

Here's the code generated for the constructor when compiled with -O2.

Clang 3.9:

        andl    $3, %esi
        leal    (%rsi,%rdx,4), %eax
        movl    %eax, (%rdi)
        retq

GCC 7.0:

        movl    %esi, %eax
        movzbl  (%rdi), %esi
        andl    $3, %eax
        andl    $-4, %esi
        orl     %eax, %esi
        leal    0(,%rdx,4), %eax
        movb    %sil, (%rdi)
        movl    (%rdi), %edx
        andl    $3, %edx
        orl     %eax, %edx
        movl    %edx, (%rdi)
        ret

Reply via email to