[LLVMdev] A case where llvm created different cfg for same code
Sheng Zhou
zhousheng at autoesl.com
Wed Aug 13 00:03:25 PDT 2008
>
> Message: 4
> Date: Tue, 12 Aug 2008 13:23:52 -0700
> From: "Bill Wendling" <isanbard at gmail.com>
> Subject: Re: [LLVMdev] A case where llvm created different cfg for
> same code
> To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Message-ID:
> <16e5fdf90808121323g1ae2a2e3lb6c5bd62521df621 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Aug 12, 2008 at 1:24 AM, Sheng Zhou <zhousheng at autoesl.com> wrote:
>
>> > Hi,
>> >
>> > The following two segments of code are actually the same,
>> > but llvm created different cfg for them.
>> >
>>
> ...
>
>> >
>> > The prime difference is that: cfg of form2 has additional basic block
>> > which has a back edge to a non-header-block
>> > I think the loop in that cfg is not canonical.
>> >
>> > I tried -loopsimplify and -indvars , but no improvement.
>> >
>> > Any comments for this? Thanks in advance.
>> >
>>
> The code is not the same. 7 is commented out in the first and 8 in the
> second. Why would you expect the CFGs to match? Is there something
> wrong (inefficient) in the resulting output of these two functions
> when compiled?
>
7 for(i=0; i<j && i+j+1<N; i++) {
8 for(i=0; i<j && i<N-j-1; i++) {
Line 7 and Line 8 actually have the same expression,
Line 8 just move the "j+1" to the right hand of the inequation.
I just wonder why the two equal inequation result in different cfg, the
additional basicblock, backedge...
Surely the two cfg are all correct, but just the additional backedge
makes it hard for loop pipeline.
Can we improve it?
> -bw
More information about the llvm-dev
mailing list