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

--- Comment #1 from SztfG at yandex dot ru ---
If array of char is initialized using string, gcc can use larger mov
instruction, like movabsq, movq, movl etc. but not movdqa, movaps or other xmm
But if zero byte appears in string, compiler always create a separate array and
copy it to stack, using various mov instruction, except xmm-based

void bar(void)
{
  char a[4] = "\x00\x02\x03\x04";
  foo(a);
}

produces

.LC0:
        .string ""
        .string "\002\003\004"

bar:
        subq    $24, %rsp
        movl    .LC0(%rip), %eax
        movq    %rsp, %rdi
        movl    %eax, (%rsp)
        call    foo
        addq    $24, %rsp
        ret

Reply via email to