This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
identifying a BB representing a self-loop
- From: "sean yang" <seanatpurdue at hotmail dot com>
- To: gcc at gcc dot gnu dot org
- Cc: seanatpurdue at purdue dot edu, dberlin at dberlin dot org
- Date: Fri, 19 May 2006 19:38:47 +0000
- Subject: identifying a BB representing a self-loop
- Bcc:
Some basic blocks may represent a (self) loop, but GCC's internal basic
block representation won't show such information explicitly (i.e., it won't
store a self-loop edge).
My question is, when I walk through basic blocks, can I identify then
easily?
E.g., Let's say,
----------demo.c------------------------------------
int main(){
int i;
int sum = 0;
for (i=0; i< 10; i++){
sum = sum+i;
}
}
-----------------------------------------------------
If we compile this by "#gcc -c -O -da demo.c, we can see there are only
three BBs. Actually, BB1 is a self-looped basic block. But this loop
information is not explicitly expressed.
BB0-->BB1-->BB2 (see details in the attached .cfg file)
---------------------cat demo.c.08.cfg---------------------------------
;; Function main
70 registers.
Register 59 used 2 times across 0 insns; set 2 times; user var; dies in 0
places.
Register 60 used 1 times across 0 insns; set 1 time; dies in 0 places.
3 basic blocks, 5 edges.
Basic block 0 prev -1, next 1, loop_depth 0, count 0, freq 1000, maybe hot.
Predecessors: ENTRY (fallthru)
Successors: 1 (fallthru)
Basic block 1 prev 0, next 2, loop_depth 1, count 0, freq 10000, maybe hot.
Predecessors: 0 (fallthru) 1
Successors: 1 2 (fallthru)
Basic block 2 prev 1, next -2, loop_depth 0, count 0, freq 1000, maybe hot.
Predecessors: 1 (fallthru)
Successors: EXIT (fallthru)
try_optimize_cfg iteration 1
(note 2 0 20 NOTE_INSN_DELETED)
;; Start of basic block 0, registers live: (nil)
(note 20 2 9 0 [bb 0] NOTE_INSN_BASIC_BLOCK)
(insn 9 20 15 0 (parallel [
(set (reg/f:SI 7 sp)
(and:SI (reg/f:SI 7 sp)
(const_int -16 [0xfffffff0])))
(clobber (reg:CC 17 flags))
]) 200 {*andsi_1} (nil)
(nil))
(insn 15 9 7 0 (parallel [
(set (reg/f:SI 7 sp)
(plus:SI (reg/f:SI 7 sp)
(const_int -16 [0xfffffff0])))
(clobber (reg:CC 17 flags))
]) 140 {*addsi_1} (nil)
(nil))
(note 7 15 22 0 NOTE_INSN_FUNCTION_BEG)
(insn 22 7 44 0 (set (reg/v:SI 59 [ i ])
(const_int 0 [0x0])) 35 {*movsi_1} (nil)
(nil))
;; End of basic block 0, registers live:
(nil)
(note 44 22 23 NOTE_INSN_LOOP_BEG)
;; Start of basic block 1, registers live: (nil)
(code_label 23 44 24 1 2 "" [1 uses])
(note 24 23 26 1 [bb 1] NOTE_INSN_BASIC_BLOCK)
(insn 26 24 27 1 (parallel [
(set (reg/v:SI 59 [ i ])
(plus:SI (reg/v:SI 59 [ i ])
(const_int 1 [0x1])))
(clobber (reg:CC 17 flags))
]) -1 (nil)
(nil))
(insn 27 26 28 1 (set (reg:CCZ 17 flags)
(compare:CCZ (reg/v:SI 59 [ i ])
(const_int 10 [0xa]))) -1 (nil)
(nil))
(jump_insn 28 27 45 1 (set (pc)
(if_then_else (ne (reg:CCZ 17 flags)
(const_int 0 [0x0]))
(label_ref 23)
(pc))) -1 (nil)
(expr_list:REG_BR_PROB (const_int 9000 [0x2328])
(nil)))
;; End of basic block 1, registers live:
(nil)
(note 45 28 31 NOTE_INSN_LOOP_END)
(note 31 45 41 NOTE_INSN_FUNCTION_END)
;; Start of basic block 2, registers live: (nil)
(note 41 31 35 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(insn 35 41 36 2 (clobber (reg/i:SI 0 ax)) -1 (nil)
(nil))
(insn 36 35 40 2 (clobber (reg:SI 60 [ <result> ])) -1 (nil)
(nil))
(insn 40 36 0 2 (use (reg/i:SI 0 ax)) -1 (nil)
(nil))
;; End of basic block 2, registers live:
(nil)
----------------------------------------------------------------
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/