This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/38740] New: Incorrect delayed branch optimization


.L1018:
        ldi 1105,%r19
        cmpb,= %r19,%r28,.L1015
        ldw 48(%r3),%r28
        cmpb,<< %r19,%r28,.L1019
        ldi 1104,%r19

The "ldw 48(%r3),%r28" instruction placed in the delay slot of the preceding
cmpb instruction clobbers %r28 and the following cmpb fails if the first
branch is not taken.

The above code snippet is from lzma.  The compilation command is:

g++ -DHAVE_CONFIG_H -I. -I../../../../../../src/sdk/7zip/Compress/LZMA
-I../../../../..    -DCOMPRESS_MF_BT -DCOMPRESS_MF_BT4 -DCOMPRESS_MF_HC -O0
-march=2.0 -g -fdelayed-branch -MT LZMAEncoder.o -MD -MP -MF
.deps/LZMAEncoder.Tpo -S -o LZMAEncoder.s
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp -da

This is the rtl from LZMAEncoder.cpp.199r.barriers:

(insn 36 453 37
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (set (reg:SI
19 %r19 [140])
        (const_int 1105 [0x451])) 37 {*pa.md:2552} (nil))

(jump_insn 37 36 454
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (set (pc)
        (if_then_else (eq (reg:SI 28 %r28 [orig:124 D.7781 ] [124])
                (reg:SI 19 %r19 [140]))
            (label_ref 124)
            (pc))) 25 {*pa.md:1780} (nil))

(note 454 37 38 [bb 10] NOTE_INSN_BASIC_BLOCK)

(insn 38 454 39
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (set (reg:SI
19 %r19 [141])
        (const_int 1105 [0x451])) 37 {*pa.md:2552} (nil))

(jump_insn 39 38 455
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (set (pc)
        (if_then_else (gtu (reg:SI 28 %r28 [orig:124 D.7781 ] [124])
                (reg:SI 19 %r19 [141]))
            (label_ref 44)
            (pc))) 25 {*pa.md:1780} (nil))

This is the rtl from LZMAEncoder.cpp.200r.dbr:

(insn 36 453 655
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:38
1 (set (reg:SI 19 %r19 [140])
        (const_int 1105 [0x451])) 37 {*pa.md:2552} (nil))
(insn 655 36 454
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (sequence [
            (jump_insn 37 36 126
../../../../../../src/sdk/7zip/Compress/LZMA/LZ
MAEncoder.cpp:381 (set (pc)
                    (if_then_else (eq (reg:SI 28 %r28 [orig:124 D.7781 ] [124])
                            (reg:SI 19 %r19 [140]))                       
(label_ref 124)
                        (pc))) 25 {*pa.md:1780} (expr_list:REG_BR_PRED
(const_in
t 17 [0x11])
                    (nil)))
            (insn/s 126 37 454 (set (reg/f:SI 28 %r28 [177])                   
(mem/f/c/i:SI (plus:SI (reg/f:SI 3 %r3)
                            (const_int 48 [0x30])) [0 prop+0 S4 A64])) 37
{*pa.m
d:2552} (nil))
        ]) -1 (nil))

(note 454 655 657 [bb 10] NOTE_INSN_BASIC_BLOCK)

(insn 657 454 455
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (sequence [
            (jump_insn 39 454 40
../../../../../../src/sdk/7zip/Compress/LZMA/LZMAEncoder.cpp:381 (set (pc)
                    (if_then_else (gtu (reg:SI 28 %r28 [orig:124 D.7781 ]
[124])
                            (reg:SI 19 %r19 [141]))
                        (label_ref 44)
                        (pc))) 25 {*pa.md:1780} (expr_list:REG_BR_PRED
(const_int 17 [0x11])
                    (nil)))
            (insn 40 39 455 (set (reg:SI 19 %r19 [142])
                    (const_int 1104 [0x450])) 37 {*pa.md:2552} (nil))
        ]) -1 (nil))


-- 
           Summary: Incorrect delayed branch optimization
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: danglin at gcc dot gnu dot org
 GCC build triplet: hppa-unknown-linux-gnu
  GCC host triplet: hppa-unknown-linux-gnu
GCC target triplet: hppa-unknown-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]