Basic blocks and compilers

Christian Christmann <plfriko@yahoo.de>
7 Jan 2006 21:44:36 -0500

          From comp.compilers

Related articles
Basic blocks and compilers plfriko@yahoo.de (Christian Christmann) (2006-01-07)
Re: Basic blocks and compilers gneuner2@comcast.net (George Neuner) (2006-01-09)
Re: Basic blocks and compilers FireMeteor.Guo@gmail.com (FireMeteor.Guo@gmail.com) (2006-01-09)
Re: Basic blocks and compilers momchil.velikov@gmail.com (2006-01-09)
Re: Basic blocks and compilers DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-01-09)
Re: Basic blocks and compilers bonzini@gnu.org (Paolo Bonzini) (2006-01-09)
Re: Basic blocks and compilers kenrose@tfb.com (Ken Rose) (2006-01-09)
[2 later articles]
| List of all articles for this month |

From: Christian Christmann <plfriko@yahoo.de>
Newsgroups: comp.compilers
Date: 7 Jan 2006 21:44:36 -0500
Organization: Arcor
Keywords: analysis, question

Hi,


I'm using the tricore-gcc v2.8.1 to generate code for my Infineon
TriCore DSP. Analyzing the generated code (compiled with -O0), I
noticed a strange behavior of the compiler. (My questions do not
concern a specific processor but more the theory behind the assembly
language.)


Here is the code for a simple C function "loopfunc" that is
called from the main function (not included):


                .file "for.c"
                # Generated by gcc 2.8.1 for TRICORE (generic)
gcc2_compiled.:
__gnu_compiled_c:
                .section .text
                .align 1
                .global loopfunc
                .type loopfunc,@function
loopfunc:
                # arg_overflow_area = 0, pretend = 0
                # frame_size = 12, outgoing_args_size = 0
                # f_size = 16, frame_pointer_needed = 0
                # pool_size = 0
                sub.a %SP, 16 # allocate space for locals
                st.w [%a10] 12, %d4
                mov %d1, 0
                st.w [%a10] 8, %d1
.L2:
                ld.w %d15, [%a10] 8
                ld.w %d0, [%a10] 12
                jlt %d15, %d0, .L5
                j .L3
.L5:
                ld.w %d15, [%a10] 4
                add %d0, %d15, 1
                st.w [%a10] 4, %d0
.L4:
                ld.w %d15, [%a10] 8
                add %d0, %d15, 1
                st.w [%a10] 8, %d0
                j .L2
.L3:
                ld.w %d15, [%a10] 4
                mov %d2, %d15
                j .L1
.L1:
                ret
                .align 1
                .global main
                .type main,@function


I don't understand why the compiler
1) is not spliting basic block .L2 into two blocks where
the second block just contains the instruction "j .L3".
I though that each re-direction of the control flow imposes the
creation of a new basic block (like .L4 and .L3). The instuction
"jlt %d15, %d0, .L5" can possibly direct the program flow to .L5 and
thus, in my opinion, the basic block should end here.
2) splits block .L5 and .L4? There are no
calls to label .L4, so, according to my understanding, all instructions
of blocks .L5 and .L4 should be held in one block.


Might these two points be bugs or do the authors of the tricore-gcc
have a different definition of basic blocks?


I would be very glad if you could shed some light on my questions.


Thank you.


Chris


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.