[LLVMdev] where are my phi-nodes?

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Sep 13 13:39:32 PDT 2010


On Sep 13, 2010, at 11:52 AM, John McCall wrote:

> On Sep 13, 2010, at 11:43 AM, Fariborz Jahanian wrote:
>> On Sep 13, 2010, at 11:11 AM, John McCall wrote:
>>> On Sep 13, 2010, at 10:58 AM, Fariborz Jahanian wrote:
>>>> 
>>> We do emit phis when the semantics aren't defined in terms of memory,
>>> e.g. with expressions that have multiple paths of control flow (like the
>>> conditional operator or null-checked derived-to-base conversions).
>> 
>> But at least for conditional operator, there are labels, conditionals and branches.
>> Optimizer should be able to build the phi nodes from control flow. I don't know
>> why not. But I am sure there is good reason for it being in the fe. (maybe it makes
>> optimizer's work easier).
> 
> Making phis explicitly in these cases does remove a small amount of work from
> the optimizer, and it produces slightly better code at -O0, but mostly it's just
> convenient.  Emitting an alloca with associated loads and stores would actually
> be less obvious.

FWIW, the fast register allocator is going to undo any -O0 performance win from phi nodes.
It spills and reloads all registers that are live across blocks.
Phi nodes are no worse than going through an alloca, though.

/jakob





More information about the llvm-dev mailing list