<div dir="ltr">This introduced a very slow compile or infinite loop problem described in <a href="http://llvm.org/PR20736">llvm.org/PR20736</a> so I have reverted it in r216307.<div><br></div><div>Nick</div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On 13 August 2014 18:07, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Author: chandlerc<br>
Date: Wed Aug 13 20:07:37 2014<br>
New Revision: 215611<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=215611&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=215611&view=rev</a><br>
Log:<br>
[SDAG] Fix a case where we would iteratively legalize a node during<br>
combining by replacing it with something else but not re-process the<br>
node afterward to remove it.<br>
<br>
In a truly remarkable stroke of bad luck, this would (in the test case<br>
attached) end up getting some other node combined into it without ever<br>
getting re-processed. By adding it back on to the worklist, in addition<br>
to deleting the dead nodes more quickly we also ensure that if it<br>
*stops* being dead for any reason it makes it back through the<br>
legalizer. Without this, the test case will end up failing during<br>
instruction selection due to an and node with a type we don't have an<br>
instruction pattern for.<br>
<br>
It took many million runs of the shuffle fuzz tester to find this.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp<br>
    llvm/trunk/test/CodeGen/X86/vector-shuffle-128-v16.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=215611&r1=215610&r2=215611&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=215611&r1=215610&r2=215611&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Aug 13 20:07:37 2014<br>
@@ -156,6 +156,8 @@ public:<br>
   // Node replacement helpers<br>
   void ReplacedNode(SDNode *N) {<br>
     LegalizedNodes.erase(N);<br>
+    if (UpdatedNodes)<br>
+      UpdatedNodes->insert(N);<br>
   }<br>
   void ReplaceNode(SDNode *Old, SDNode *New) {<br>
     DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG);<br>
<br>
Modified: llvm/trunk/test/CodeGen/X86/vector-shuffle-128-v16.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vector-shuffle-128-v16.ll?rev=215611&r1=215610&r2=215611&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vector-shuffle-128-v16.ll?rev=215611&r1=215610&r2=215611&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/test/CodeGen/X86/vector-shuffle-128-v16.ll (original)<br>
+++ llvm/trunk/test/CodeGen/X86/vector-shuffle-128-v16.ll Wed Aug 13 20:07:37 2014<br>
@@ -269,3 +269,23 @@ define <16 x i8> @trunc_v4i32_shuffle(<1<br>
   %shuffle = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef><br>


   ret <16 x i8> %shuffle<br>
 }<br>
+<br>
+define <16 x i8> @stress_test0(<16 x i8> %s.0.1, <16 x i8> %s.0.2, <16 x i8> %s.0.3, <16 x i8> %s.0.4, <16 x i8> %s.0.5, <16 x i8> %s.0.6, <16 x i8> %s.0.7, <16 x i8> %s.0.8, <16 x i8> %s.0.9) {<br>


+; We don't have anything useful to check here. This generates 100s of<br>
+; instructions. Instead, just make sure we survived codegen.<br>
+;<br>
+; ALL-LABEL: @stress_test0<br>
+; ALL: retq<br>
+entry:<br>
+  %s.1.4 = shufflevector <16 x i8> %s.0.4, <16 x i8> %s.0.5, <16 x i32> <i32 1, i32 22, i32 21, i32 28, i32 3, i32 16, i32 6, i32 1, i32 19, i32 29, i32 12, i32 31, i32 2, i32 3, i32 3, i32 6><br>


+  %s.1.5 = shufflevector <16 x i8> %s.0.5, <16 x i8> %s.0.6, <16 x i32> <i32 31, i32 20, i32 12, i32 19, i32 2, i32 15, i32 12, i32 31, i32 2, i32 28, i32 2, i32 30, i32 7, i32 8, i32 17, i32 28><br>


+  %s.1.8 = shufflevector <16 x i8> %s.0.8, <16 x i8> %s.0.9, <16 x i32> <i32 14, i32 10, i32 17, i32 5, i32 17, i32 9, i32 17, i32 21, i32 31, i32 24, i32 16, i32 6, i32 20, i32 28, i32 23, i32 8><br>


+  %s.2.2 = shufflevector <16 x i8> %s.0.3, <16 x i8> %s.0.4, <16 x i32> <i32 20, i32 9, i32 21, i32 11, i32 11, i32 4, i32 3, i32 18, i32 3, i32 30, i32 4, i32 31, i32 11, i32 24, i32 13, i32 29><br>


+  %s.3.2 = shufflevector <16 x i8> %s.2.2, <16 x i8> %s.1.4, <16 x i32> <i32 15, i32 13, i32 5, i32 11, i32 7, i32 17, i32 14, i32 22, i32 22, i32 16, i32 7, i32 24, i32 16, i32 22, i32 7, i32 29><br>


+  %s.5.4 = shufflevector <16 x i8> %s.1.5, <16 x i8> %s.1.8, <16 x i32> <i32 3, i32 13, i32 19, i32 7, i32 23, i32 11, i32 1, i32 9, i32 16, i32 25, i32 2, i32 7, i32 0, i32 21, i32 23, i32 17><br>


+  %s.6.1 = shufflevector <16 x i8> %s.3.2, <16 x i8> %s.3.2, <16 x i32> <i32 11, i32 2, i32 28, i32 31, i32 27, i32 3, i32 9, i32 27, i32 25, i32 25, i32 14, i32 7, i32 12, i32 28, i32 12, i32 23><br>


+  %s.7.1 = shufflevector <16 x i8> %s.6.1, <16 x i8> %s.3.2, <16 x i32> <i32 15, i32 29, i32 14, i32 0, i32 29, i32 15, i32 26, i32 30, i32 6, i32 7, i32 2, i32 8, i32 12, i32 10, i32 29, i32 17><br>


+  %s.7.2 = shufflevector <16 x i8> %s.3.2, <16 x i8> %s.5.4, <16 x i32> <i32 3, i32 29, i32 3, i32 19, i32 undef, i32 20, i32 undef, i32 3, i32 27, i32 undef, i32 undef, i32 11, i32 undef, i32 undef, i32 undef, i32 undef><br>


+  %s.16.0 = shufflevector <16 x i8> %s.7.1, <16 x i8> %s.7.2, <16 x i32> <i32 13, i32 1, i32 16, i32 16, i32 6, i32 7, i32 29, i32 18, i32 19, i32 28, i32 undef, i32 undef, i32 31, i32 1, i32 undef, i32 10><br>


+  ret <16 x i8> %s.16.0<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>