[LLVMdev] [LLVM, loop-unswitch tests] preserve-analyses.ll, strange PHI instruction.
Nick Lewycky
nicholas at mxc.ca
Wed Nov 9 00:12:23 PST 2011
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
More information about the llvm-dev
mailing list