<div dir="ltr">Yes, the original implementation used single operand phi nodes, and besides chandler being against it for various reasons, you can't handle assume, or other middle-of-the-block instructions while doing it.<div><br></div><div><div>In particular, there is not necessarily a placement point you can use where you can insert a single operand phi node.</div><div><br></div><div>(It is obviously possible to handle all branch instructions, however, assuming you don't care about critical edges, because then you can't place a single operand one in the successors)</div><div><br></div><div>Example:<br><br></div><div>%foo = add i32 0, %a</div><div>%bob = icmp eq i32 %foo, 0</div><div>call llvm.assume(%bob)</div><div><br></div><div>There is no place i can place a single operand phi for %foo or %bob and have it cover everything it should.</div><div><br></div><div>I can't place it in this block, because it would not dominate the definition of %foo or %bob</div><div><br></div><div>Normally, with branches, you could place it in the successor block.</div><div>However, i have a patch to support critical edges, so once tha goes in, you  have no guarantee the successors are not blocks with multiple preds.</div><div><br></div><div>In that situation, the only safe insertion point is right before the assume/branch/switch, and you can't put a phi there.</div><div><br></div></div><div>If you stare at the critical edges support that is upcoming, you'll come to the conclusion that you can't even "fudge it" well.</div><div><br></div><div>The in-between state that used to exist was "we'd create single operand phis where we could, and ssa.copy where we couldn't", but that just seems more confusing, so i just went with ssa copy everywhere.</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 10, 2017 at 10:03 AM, Philip Reames <span dir="ltr"><<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Out of curiosity, how is @llvm.ssa_copy different from a single entry phi node?  We already use redundant PHI nodes in LCSSA, doing the same here would seem to make sense.<span class="HOEnZb"><font color="#888888"><br>
<br>
Philip</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 02/07/2017 11:29 AM, Daniel Berlin via llvm-commits wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: dannyb<br>
Date: Tue Feb  7 13:29:25 2017<br>
New Revision: 294341<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=294341&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=294341&view=rev</a><br>
Log:<br>
This patch adds a ssa_copy intrinsic, as part of splitting up D29316.<br>
<br>
Summary:<br>
The intrinsic, marked as returning it's first argument, has no code<br>
generation effect (though currently not every optimization pass knows<br>
that intrinsics with the returned attribute can be looked through).<br>
<br>
It is about to be used to by the PredicateInfo pass to attach<br>
predicate information to existing operands, and be able to tell what<br>
the predicate information affects.<br>
<br>
We deliberately do not attach any info through a second operand so<br>
that the intrinsics do not need to dominate the comparisons/etc (since<br>
in the case of assume, we may want to push them up the post-dominator<br>
tree).<br>
<br>
Reviewers: davide, sanjoy<br>
<br>
Subscribers: llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D29517" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2951<wbr>7</a><br>
<br>
Modified:<br>
     llvm/trunk/docs/LangRef.rst<br>
     llvm/trunk/include/llvm/IR/In<wbr><a href="http://trinsics.td">trinsics.td</a><br>
<br>
Modified: llvm/trunk/docs/LangRef.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=294341&r1=294340&r2=294341&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/docs/LangRef.<wbr>rst?rev=294341&r1=294340&r2=<wbr>294341&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/docs/LangRef.rst (original)<br>
+++ llvm/trunk/docs/LangRef.rst Tue Feb  7 13:29:25 2017<br>
@@ -12700,6 +12700,33 @@ sufficient overall improvement in code q<br>
  that the optimizer can otherwise deduce or facts that are of little use to the<br>
  optimizer.<br>
  +.. _int_ssa_copy:<br>
+<br>
+'``llvm.ssa_copy``' Intrinsic<br>
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<wbr>^^^^^^<br>
+<br>
+Syntax:<br>
+"""""""<br>
+<br>
+::<br>
+<br>
+      declare type @llvm.ssa_copy(type %operand) returned(1) readnone<br>
+<br>
+Arguments:<br>
+""""""""""<br>
+<br>
+The first argument is an operand which is used as the returned value.<br>
+<br>
+Overview:<br>
+""""""""""<br>
+<br>
+The ``llvm.ssa_copy`` intrinsic can be used to attach information to<br>
+operations by copying them and giving them new names.  For example,<br>
+the PredicateInfo utility uses it to build Extended SSA form, and<br>
+attach various forms of information to operands that dominate specific<br>
+uses.  It is not meant for general use, only for building temporary<br>
+renaming forms that require value splits at certain points.<br>
+<br>
  .. _type.test:<br>
    '``llvm.type.test``' Intrinsic<br>
<br>
Modified: llvm/trunk/include/llvm/IR/Int<wbr><a href="http://rinsics.td">rinsics.td</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.td?rev=294341&r1=294340&r2=294341&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>IR/Intrinsics.td?rev=294341&<wbr>r1=294340&r2=294341&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/IR/Int<wbr><a href="http://rinsics.td">rinsics.td</a> (original)<br>
+++ llvm/trunk/include/llvm/IR/Int<wbr><a href="http://rinsics.td">rinsics.td</a> Tue Feb  7 13:29:25 2017<br>
@@ -781,6 +781,10 @@ def int_memcpy_element_atomic  : Intrins<br>
                                   [IntrArgMemOnly, NoCapture<0>, NoCapture<1>,<br>
                                    WriteOnly<0>, ReadOnly<1>]>;<br>
  +//===----- Intrinsics that are used to provide predicate information -----===//<br>
+<br>
+def int_ssa_copy : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],<br>
+                            [IntrNoMem, Returned<0>]>;<br>
  //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
  // Target-specific intrinsics<br>
  //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote>
<br>
<br>
</div></div></blockquote></div><br></div>