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

Robert Dubner <rdubner at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Robert Dubner <rdubner at gcc dot gnu.org> ---
This is by no means the end of the effort to produce more efficient code.  But
in this particular case, the program

~~~~~~~
         PROGRAM-ID. STRMOV.
         DATA DIVISION.
         WORKING-STORAGE SECTION.
         77 foo  pic x(10).
         PROCEDURE DIVISION.
         move 'A' to foo (1:1)
         move 'B' to foo (2:1)
         move 'C' to foo (3:1)
         STOP RUN.
~~~~~~~~

compiled with -O0, now produces this fragment of x86_64 machine language:

        .loc 1 6 10 is_stmt 1
        movq    foo.73.0(%rip), %rax
        movl    $0, %edx
        addq    %rdx, %rax
        movb    $65, (%rax)
        .loc 1 7 10
        movq    foo.73.0(%rip), %rax
        movl    $1, %edx
        addq    %rdx, %rax
        movb    $66, (%rax)
        .loc 1 8 10
        movq    foo.73.0(%rip), %rax
        movl    $2, %edx
        addq    %rdx, %rax
        movb    $67, (%rax)
        .loc 1 9 10
        movzwl  __gg__data_return_code(%rip), %eax

That's four instructions per MOVE.  Compiled with -O2, it gets down to two
instructions per MOVE:

        .loc 1 6 10 view .LVU38
        movq    foo.73.0(%rip), %rax
        movb    $65, (%rax)
        .loc 1 7 10 view .LVU39
        movq    foo.73.0(%rip), %rax
        movb    $66, 1(%rax)
        .loc 1 8 10 view .LVU40
        movq    foo.73.0(%rip), %rax
        movb    $67, 2(%rax)
        .loc 1 9 10 view .LVU41
        movswl  __gg__data_return_code(%rip), %edi

I feel justified in closing this PR.

Reply via email to