<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 10:44 AM, River Riddle <span dir="ltr"><<a href="mailto:riddleriver@gmail.com" target="_blank">riddleriver@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey Dan,<div><div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Aug 1, 2017 at 10:28 AM, Daniel Berlin via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">Also as a side note, I think in the original MachineOutliner RFC thread there was some confusion as to whether it was possible to solve the code folding outlining problem exactly as a graph problem on SSA using standard value numbering algorithms in polynomial time.</div></div></div></blockquote><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><div dir="auto" style="font-family:sans-serif"> I can elaborate further, but</div><div dir="auto" style="font-family:sans-serif">1. it is easy to see that you can map an arbitrary dag to an isomorphic data flow graph in an SSA IR e.g. in LLVM IR or pre-RA MIR</div></div></div></blockquote><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><div dir="auto" style="font-family:sans-serif">2. Given two dags, you can create their respective isomorphic data flow graphs (say, put them into two separate functions)</div><div dir="auto" style="font-family:sans-serif">3. An exact graph based code folding outliner would be able to discover if the two dataflow graphs are isomorphic (that is basically what I mean by exact) and outline them.</div><div dir="auto" style="font-family:sans-serif">4. Thus, graph isomorphism on dags can be solved with such an algorithm and thus the outlining problem is GI-hard and a polynomial time solution would be a big breakthrough in CS.</div></div></div></blockquote><div><br></div></span><div>First, you'd have to reduce them in both directions to prove that ;)</div><div><br></div><div>All that's been shown is that you can reduce it to a hard problem.</div><div>You can also reduce it to 3-sat., but that doesn't mean anything unless you can reduce 3-sat to it.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><div dir="auto" style="font-family:sans-serif">5. The actual problem the outliner is trying to solve is actually more like finding subgraphs that are isomorphic, making the problem even harder (something like "given dags A and B does there exist a subgraph of A that is isomorphic to a subgraph of B")</div><div dir="auto" style="font-family:sans-serif"><br></div></div></div></blockquote><div><br></div></span><div>This assumes, strongly, that this reduction is the way to do it, and also that SSA/etc imparts no structure in the reduction that enables you to solve it faster (IE restricts the types of graphs, etc)</div><div> <br></div><div>FWIW, the exact argument above holds for value numbering, and since the days of kildall, it was believed not solvable in a complete fashion in less than exponential time due to the need to do graph isomorphism on large value graphs at join points.</div><div><br></div><div>Except, much like RA and other things, it turns out this is not right for SSA, and in the past few years, it was proved you could do complete  value numbering in polynomial time on SSA.</div><div><br></div><div>So with all due respect to quentin, i don't buy it yet.</div><div><br></div><div>Without more, i'd bet using similar techniques to solve value numbering in polynomial time to SSA could be applied here.</div><div><br></div><div>This is because the complete polynomial value numbering techniques are in fact, value graph isomorphism ....</div><div><br></div><div>So i'd assume the opposite (it can be done in polynomial time) without more.</div></div></div></div></blockquote><div> </div></div></div><div>If you are willing to point me in the right direction, I am more than willing to implement/adapt to this type of solution for candidate selection.</div><div>Thanks,</div><div> River Riddle</div></div></div></div></div></div></blockquote><div><br></div><div>Though i'm happy to have this tangent discussion because i think it's interesting, realistically, I'm not sure it's worth it ATM when you've got stuff that works pretty well.  So i'm going to drop off and let you concentrate on *this* patch, because i think that's what we should start with, realistically.</div><div><br></div><div>I just don't want us to declare it "impossible" without actual  proof.  Ken Zadeck told me when he first tried to show that he could solve "thought-to-be-N^3" dataflow problems in linear time, the response get got was "that's impossible and i can prove it", and it turns out they were wrong :)</div><div><br></div></div></div></div>