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

            Bug ID: 58384
           Summary: [4.9 regression] Runfail on spec2000/253.perlbmk if
                    lto and pre-reload scheduler is used on x86 after
                    r200133.
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ysrumyan at gmail dot com

We also assume that arm can have the same problem at given benchmark if -flto
is used to compile since pre-reload scheduler is used by default on it.

The issue can be reproduced at attached test-case extracted from 253.perlbmk
sources (function Perl_pp_entersub, file pp_hot.c).

Before r200133 forward propagation (fwprop1 for rtl) performs substitution of
stored value to subsequent load with the same base, but after this fix does
not.
Looking at assembly files for test-case we can see that
  -- before fix --

    call    realloc
    movq    (%rbx), %r8
    movq    %rax, %r9
    movq    %rax, %rcx
    movq    8(%rsp), %rdx
    movq    %rax, 24(%r8)
    movq    %rax, (%r8)
    jmp    .L4
 i.e. return value of 'realloc' is copied to %r9 and %rcx which correspondent
to pre temporaries.

  -- after fix -- (without pre-reload scheduler)

    call    realloc
    movq    (%rbx), %rcx
    movq    (%rbx), %r8
    movq    8(%rsp), %rdx
    movq    %rax, 24(%rcx)
    movq    %rax, (%rcx)
    movq    (%r8), %rcx  <--- redundant load
    movq    %rcx, %rax
    jmp    .L4

i.w. we can see redundant load from %r8.

But if we turn on pre-reload scheduler, this load will be unlegal hoisted cross
interleaved store (we got RT error on 253.perlbmk) and we can see it in
assembly:

    call    realloc
    movq    (%rbx), %r8
    movq    8(%rsp), %rdx
    movq    (%r8), %rcx  <--- non-legal code motion
    movq    %rax, 24(%r8)
    movq    %rax, (%r8)
    movq    %rcx, %rax
    jmp    .L4
To reproduce compile attached test-case with options
-Ofast -march=corei7 -fschedule-insns --param sched-pressure-algorithm=1
-fsched-pressure

Reply via email to