[LLVMdev] [LLVM, loop-unswitch tests] preserve-analyses.ll, strange PHI instruction.

Duncan Sands baldrick at free.fr
Wed Nov 9 01:44:22 PST 2011


Hi Stepan,

> OK. Thanks. And if I removed "case 4:" for example. Need I scan all phi
> nodes and fix it, by removing one predecessor (if it exists) to switch's
> parent block?

you can use removePredecessor (a BasicBlock method).  That will remove
one copy of the predecessor from all phi nodes.

Ciao, Duncan.

>
> -Stepan.
>
> Nick Lewycky wrote:
>> Stepan Dyatkovskiy wrote:
>>> Hi all.
>>>
>>> Looking at test/Transforms/LoopUnswitch/preserve-analyses.ll, I found
>>> improper phi instruction at string #122:
>>> %call.i25.lcssa48 = phi i8* [ %call.i25, %if.then31.i.i ], [ %call.i25,
>>> %if.then31.i.i ] ;<i8*>  [#uses=0]
>>> Is it trick or mistake?
>>
>> What's improper about it?
>>
>> The block may have two predecessors, both of which are the same block
>> (consider a switch statement with "case 3: case 4: code;"). This is
>> called a critical edge. The requirement in the IR is that a PHI node
>> have an entry for each pred (including duplicates for critical edges)
>> and that the incoming value must be the same.
>>
>> The best test is to ask the verifier (opt -verify). It knows all the
>> special rules, like why this code is legal:
>>
>> define i32 @test() {
>> unreachable
>>
>> %a = add i32 %a, %a
>> ret i32 %a
>> }
>>
>> Surprise! That one's my favourite example.
>>
>> Nick
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list