------- Comment #2 from yakov at emc dot com  2007-05-22 17:44 -------
Subject: Re:  Basic block reordering creates two images of bb2,

What do you mean "jump into an inline-asm without many troubles."?
Many troubles during execution or run-time?

Please, look at *.bbro file made by:
===========================
gcc -O2 -v -dB -c reord-bb.c
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2
--enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --program-suffix=-4.1
--enable-version-specific-runtime-libs --without-system-libunwind
--with-cpu=generic --host=i586-suse-linux
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)
 /usr/lib/gcc/i586-suse-linux/4.1.2/cc1 -quiet -v reord-bb.c -quiet
-dumpbase reord-bb.c -dB -mtune=generic -auxbase reord-bb -O2 -version
-o /tmp/ccp5g56g.s

;; Function main (main)



try_optimize_cfg iteration 1



try_optimize_cfg iteration 1

STC - round 1
Getting bb 0
Basic block 0 was visited in trace 0
Block 2 can't be copied because its size = 267.
  Possible start of next round: 1 (key: -2622)
Basic block 2 was visited in trace 0
STC - round 2
Getting bb 1
Basic block 1 was visited in trace 1
STC - round 3
STC - round 4
Trace 1 (round 1):  0 [10000] 2 [10000]
Trace 2 (round 2):  1 [2622]
Block 2 can't be copied because its size = 267.
Final order:
0 2 1

3 basic blocks, 5 edges.

Basic block 0 prev -1, next 1, loop_depth 0, count 0, freq 10000, maybe hot.
Predecessors:  ENTRY [100.0%]  (fallthru)
Successors:  2 [73.8%]  (can_fallthru) 1 [26.2%]  (fallthru,can_fallthru)
Registers live at start: 6 [bp] 7 [sp] 20 [frame]
Registers live at end: 6 [bp] 7 [sp] 20 [frame]

Basic block 1 prev 0, next 2, loop_depth 0, count 0, freq 2622, maybe hot.
Predecessors:  0 [26.2%]  (fallthru,can_fallthru)
Successors:  2 [100.0%]  (fallthru,can_fallthru)
Registers live at start: 6 [bp] 7 [sp] 20 [frame]
Registers live at end: 6 [bp] 7 [sp] 20 [frame]

Basic block 2 prev 1, next -2, loop_depth 0, count 0, freq 10000, maybe hot.
Predecessors:  0 [73.8%]  (can_fallthru) 1 [100.0%]  (fallthru,can_fallthru)
Successors:  EXIT [100.0%]
Registers live at start: 6 [bp] 7 [sp] 20 [frame]
Registers live at end: 0 [ax] 6 [bp] 7 [sp] 20 [frame]

Emitting label for block 1
Reordered sequence:
 0 bb 0  [10000]
 1 bb 2  [10000]
 2 bb 1  [2622]


try_optimize_cfg iteration 1

(note:HI 2 0 7 NOTE_INSN_DELETED)

(note:HI 7 2 10 NOTE_INSN_FUNCTION_BEG)

;; Start of basic block 0, registers live: 6 [bp] 7 [sp] 20 [frame]
(note:HI 10 7 44 0 [bb 0] NOTE_INSN_BASIC_BLOCK)

(insn/f 44 10 45 0 (set (reg:SI 2 cx)
        (plus:SI (reg/f:SI 7 sp)
            (const_int 4 [0x4]))) 144 {*lea_1} (nil)
    (expr_list:REG_FRAME_RELATED_EXPR (parallel [
                (set/f (reg:SI 2 cx)
                    (unspec [
                            (const_int 0 [0x0])
                        ] 15))
                (set/f (reg:SI 2 cx)
                    (unspec [
                            (reg/f:SI 7 sp)
                        ] 14))
            ])
        (nil)))

(insn 45 44 46 0 (parallel [
            (set (reg/f:SI 7 sp)
                (and:SI (reg/f:SI 7 sp)
                    (const_int -16 [0xfffffff0])))
            (clobber (reg:CC 17 flags))
        ]) 208 {*andsi_1} (nil)
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(insn/f 46 45 47 0 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [0 S4 A8])
        (mem/c:SI (plus:SI (reg:SI 2 cx)
                (const_int -4 [0xfffffffc])) [2 S4 A8])) 28 {*pushsi2} (nil)
    (expr_list:REG_FRAME_RELATED_EXPR (set (reg/f:SI 7 sp)
            (unspec [
                    (const_int 4 [0x4])
                ] 15))
        (nil)))

(insn/f 47 46 48 0 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [0 S4 A8])
        (reg/f:SI 6 bp)) 28 {*pushsi2} (nil)
    (nil))

(insn/f 48 47 49 0 (set (reg/f:SI 6 bp)
        (reg/f:SI 7 sp)) 34 {*movsi_1} (nil)
    (nil))

(insn/f 49 48 50 0 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [0 S4 A8])
        (reg:SI 2 cx)) 28 {*pushsi2} (nil)
    (expr_list:REG_DEAD (reg:SI 2 cx)
        (nil)))

(insn/f 50 49 51 0 (parallel [
            (set (reg/f:SI 7 sp)
                (plus:SI (reg/f:SI 7 sp)
                    (const_int -4 [0xfffffffc])))
            (clobber (reg:CC 17 flags))
            (clobber (mem:BLK (scratch) [0 A8]))
        ]) 542 {pro_epilogue_adjust_stack_1} (nil)
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(note 51 50 12 0 NOTE_INSN_PROLOGUE_END)

(call_insn:HI 12 51 60 0 (set (reg:SI 0 ax)
        (call (mem:QI (symbol_ref:SI ("bar") [flags 0x41] <function_decl
0xb7d13180 bar>) [0 S1 A8])
            (const_int 0 [0x0]))) 546 {*call_value_0} (nil)
    (nil)
    (nil))

(insn 60 12 15 0 (parallel [
            (set (reg:CCZ 17 flags)
                (compare:CCZ (reg:SI 0 ax [orig:58 D.1296 ] [58])
                    (const_int 1 [0x1])))
            (clobber (reg:SI 0 ax [orig:58 D.1296 ] [58]))
        ]) 151 {*addsi_4} (nil)
    (expr_list:REG_DEAD (reg:SI 0 ax [orig:58 D.1296 ] [58])
        (expr_list:REG_UNUSED (reg:SI 0 ax [orig:58 D.1296 ] [58])
            (nil))))

(jump_insn:HI 15 60 20 0 (set (pc)
        (if_then_else (eq (reg:CCZ 17 flags)
                (const_int 0 [0x0]))
            (label_ref:SI 63)
            (pc))) 365 {*jcc_1} (insn_list:REG_DEP_TRUE 14 (nil))
    (expr_list:REG_DEAD (reg:CCZ 17 flags)
        (expr_list:REG_BR_PROB (const_int 2622 [0xa3e])
            (nil))))
;; End of basic block 0, registers live:
 6 [bp] 7 [sp] 20 [frame]

;; Start of basic block 1, registers live: 6 [bp] 7 [sp] 20 [frame]
(code_label:HI 20 15 21 1 2 "" [1 uses])

(note:HI 21 20 23 1 [bb 1] NOTE_INSN_BASIC_BLOCK)

(insn:HI 23 21 25 1 (asm_input/v (".globl  pushAndEnd")) -1 (nil)
    (nil))

(insn:HI 25 23 29 1 (asm_input/v ("pushAndEnd:")) -1 (nil)
    (nil))

(note:HI 29 25 59 1 NOTE_INSN_FUNCTION_END)

(insn 59 29 38 1 (parallel [
            (set (reg/i:SI 0 ax [ <result> ])
                (const_int 0 [0x0]))
            (clobber (reg:CC 17 flags))
        ]) 32 {*movsi_xor} (nil)
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(insn 38 59 52 1 (use (reg/i:SI 0 ax [ <result> ])) -1
(insn_list:REG_DEP_TRUE 32 (nil))
    (nil))

(note 52 38 53 1 NOTE_INSN_EPILOGUE_BEG)

(insn 53 52 54 1 (parallel [
            (set (reg/f:SI 7 sp)
                (plus:SI (reg/f:SI 7 sp)
                    (const_int 4 [0x4])))
            (clobber (reg:CC 17 flags))
            (clobber (mem:BLK (scratch) [0 A8]))
        ]) 542 {pro_epilogue_adjust_stack_1} (nil)
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(insn 54 53 55 1 (parallel [
            (set (reg:SI 2 cx)
                (mem:SI (reg/f:SI 7 sp) [0 S4 A8]))
            (set (reg/f:SI 7 sp)
                (plus:SI (reg/f:SI 7 sp)
                    (const_int 4 [0x4])))
        ]) 31 {popsi1} (nil)
    (nil))

(insn 55 54 56 1 (parallel [
            (set (reg/f:SI 6 bp)
                (mem:SI (reg/f:SI 7 sp) [0 S4 A8]))
            (set (reg/f:SI 7 sp)
                (plus:SI (reg/f:SI 7 sp)
                    (const_int 4 [0x4])))
        ]) 31 {popsi1} (nil)
    (nil))

(insn 56 55 57 1 (parallel [
            (set (reg/f:SI 7 sp)
                (plus:SI (reg:SI 2 cx)
                    (const_int -4 [0xfffffffc])))
            (clobber (reg:CC 17 flags))
        ]) 148 {*addsi_1} (nil)
    (expr_list:REG_DEAD (reg:SI 2 cx)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))

(jump_insn 57 56 58 1 (return) 389 {return_internal} (nil)
    (nil))
;; End of basic block 1, registers live:
 0 [ax] 6 [bp] 7 [sp] 20 [frame]

(barrier 58 57 63)

;; Start of basic block 2, registers live: 6 [bp] 7 [sp] 20 [frame]
(code_label 63 58 17 2 6 "" [1 uses])

(note:HI 17 63 19 2 [bb 2] NOTE_INSN_BASIC_BLOCK)

(call_insn:HI 19 17 64 2 (call (mem:QI (symbol_ref:SI ("foo") [flags
0x41] <function_decl 0xb7d13100 foo>) [0 S1 A8])
        (const_int 0 [0x0])) 385 {*call_0} (nil)
    (nil)
    (nil))

(jump_insn 64 19 65 2 (set (pc)
        (label_ref 20)) -1 (nil)
    (nil))
;; End of basic block 2, registers live:
 6 [bp] 7 [sp] 20 [frame]

(barrier 65 64 43)

(note 43 65 0 NOTE_INSN_DELETED)

and you would be able to find this duplication.

sincerely,
yakov



pinskia at gcc dot gnu dot org wrote:
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2007-05-22 17:12 
> -------
> No, what GCC is doing is correct, it is ok to duplicate Basic blocks.  What 
> you
> are doing with the inline-asm is incorrect as you  cannot jump into an
> inline-asm without many troubles.
>
>
>   


-- 


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

Reply via email to