http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54904



             Bug #: 54904

           Summary: Large mode constant live in a register not used to

                    optimize smaller mode constants

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: target

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: ja...@gcc.gnu.org

                CC: u...@gcc.gnu.org





void

foo (char *p)

{

  __builtin_memset (p, 0x11, 23);

}



results in terrible code on x86_64-linux at -O2:

        movabsq $1229782938247303441, %rax

        movl    $286331153, 16(%rdi)

        movb    $17, 22(%rdi)

        movq    %rax, (%rdi)

        movq    %rax, 8(%rdi)

        movl    $4369, %eax

        movw    %ax, 20(%rdi)

        ret

E.g.

        movabsq $1229782938247303441, %rax

        movl    %eax, 16(%rdi)

        movb    %al, 22(%rdi)

        movq    %rax, (%rdi)

        movq    %rax, 8(%rdi)

        movw    %ax, 20(%rdi)

        ret

would be 10 bytes shorter.  Guess we don't want to do this kind of

optimizations before RA, it might increase register preassure, but somewhere

close to final would be nice.  Use a register instead of immediate if it is

available, makes the insn smaller and not slower.

Reply via email to