<p dir="ltr"><br>
On Jun 29, 2015 3:16 AM, "Evgeny Astigeevich" <<a href="mailto:evgeny.astigeevich@arm.com">evgeny.astigeevich@arm.com</a>> wrote:<br>
><br>
> Hi Anirudh,<br>
><br>
> 'x' has a control dependency on 'y' because the value assigned to 'x'<br>
> depends on a path selected. This dependency can be converted into a data<br>
> dependency by means of a 'select' instruction because the control flow is<br>
> simple.<br>
> What is the problem with using phi-functions in DFG? Yes they require more<br>
> work to find out what they depend on.<br>
></p>
<p dir="ltr">Thank you for your response. Going by your definition, x is control dependent on y. To extract this control dependency, do I need to maintain path conditions for each basic block or can I do something simpler?</p>
<p dir="ltr">Also, I feel like this should be a recurring problem. Could you point me to any code example that identifies all dependencies (control and data) for phi instructions?</p>
<p dir="ltr">> Kind regards,<br>
> Evgeny Astigeevich<br>
><br>
> -----Original Message-----<br>
> From: <a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a>] On<br>
> Behalf Of Anirudh Sivaraman<br>
> Sent: 29 June 2015 07:25<br>
> To: LLVM Developers Mailing List<br>
> Subject: [LLVMdev] Inferring dependencies in phi instructions<br>
><br>
> I am trying to infer data dependencies using LLVM's def-use chains and I am<br>
> having trouble dealing with 'phi' instructions. Specifically,<br>
><br>
> If I am given the code snippet:<br>
><br>
> int foo() {<br>
> int y = 1;<br>
> int x;<br>
> if (y) {<br>
> x = 2;<br>
> } else {<br>
> x = 3;<br>
> }<br>
> return x;<br>
> }<br>
><br>
> Here, x has a data dependence on y (not control because x is assigned in<br>
> both halves), but LLVM expresses 'x' as: %x.0 = phi i32 [ 2, %2 ], [ 3, %3 ]<br>
> using phi-nodes, omitting the dependence on y.<br>
><br>
> If I write the function as:<br>
><br>
> int foo() {<br>
> int y = 1;<br>
> int x = y ? 2 : 3;<br>
> return x;<br>
> },<br>
><br>
> the dependencies work out alright because LLVM now uses a select<br>
> instruction, where the dependence on y is explicit:<br>
><br>
> %y = select i1 %x, i32 2, i32 3<br>
><br>
> In general, I don't think I can convert phi nodes into select statements<br>
> (because a phi node can refer to values from more than two paths in general,<br>
> while select statements permit only two options, one each for a true and a<br>
> false branch). Any thoughts on how this is handled in practice would be very<br>
> helpful.<br>
><br>
> Anirudh<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
><br>
</p>