<p dir="ltr">I have a patch I've been testing to clean up a lot of the passes around the vectorizers. I'll add this in and finish testing it, then send it out with numbers.</p>
<div class="gmail_quote">On Oct 9, 2014 12:40 PM, "Andrew Trick" <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Oct 9, 2014, at 8:48 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:</div><br><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">----- Original Message -----</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">From: "Arnold Schwaighofer" <<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>><br>To: "Zinovy Nis" <<a href="mailto:zinovy.nis@gmail.com" target="_blank">zinovy.nis@gmail.com</a>><br>Cc: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>, "LLVM Commits" <<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>>, "Tobias Grosser" <<a href="mailto:tobias@grosser.es" target="_blank">tobias@grosser.es</a>>,<br>"Chandler Carruth" <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>>, "Nadav Rotem" <<a href="mailto:nrotem@apple.com" target="_blank">nrotem@apple.com</a>><br>Sent: Thursday, October 9, 2014 10:07:42 AM<br>Subject: Re: SLP/Loop vectorizer pass ordering<br><br><br>The loop vectorizer now sees this loop:<br><br>define void<br>@_Z21ambient_occlusion_vecP6_IsectR5vrandILm8EE(%struct._Isect*<br>nocapture %isect, %class.vrand* nocapture readonly<br>dereferenceable(32) %rng) #0 {<br>entry:<br> br label %for.body<br><br>for.body:                                         ; preds =<br>%for.inc.for.body_crit_edge, %entry<br> %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next,<br> %for.inc.for.body_crit_edge ]<br> %occlusion.017 = phi float [ 1.000000e+00, %entry ], [ %phitmp,<br> %for.inc.for.body_crit_edge ]<br> %exitcond = icmp eq i64 %indvars.iv, 63<br> br i1 %exitcond, label %for.end, label %for.inc.for.body_crit_edge<br><br>for.inc.for.body_crit_edge:                       ; preds = %for.body<br> %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1<br> %phitmp = fadd fast float %occlusion.017, 1.000000e+00<br> br label %for.body<br><br>for.end:                                          ; preds = %for.body<br> %occlusion.017.lcssa = phi float [ %occlusion.017, %for.body ]<br> %t5 = getelementptr inbounds %struct._Isect* %isect, i64 0, i32 0<br> store float %occlusion.017.lcssa, float* %t5, align 4, !tbaa !1<br> ret void<br>}<br><br>Notice that the loop exit block is the loop header and the latch is<br>not guaranteed to be executed. The loop vectorizer assumes such<br>loops have been rotated.<br><br><br>If we send this IR through loop-rotate it will vectorize.<br><br>The farther away we move the loop vectorizer from loop rotate the<br>likelier some optimization will destroy the rotated from. We might<br>just want to run loop rotate before the loop vectorizer ...<br><br></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">I think that makes sense -- and I don't recall loop rotation being expensive, plus is preserves just about everything (and I think does a reasonable job cleaning up after itself) ;)</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">I'd say we run some benchmarks, and barring any issues, we just do it.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div></blockquote><div><br></div><div>Well, that is a classic candidate for rotate. So assuming whatever GVN is doing is sane, then I’d say it makes sense to rerun rotation.</div><div><br></div><div>-Andy</div><div><br></div><br><blockquote type="cite"><div><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><br><blockquote type="cite">On Oct 9, 2014, at 1:15 AM, Zinovy Nis <<a href="mailto:zinovy.nis@gmail.com" target="_blank">zinovy.nis@gmail.com</a>><br>wrote:<br><br>Hi.<br><br>Did you have a chance to look at my reproducer?<br><br>2014-10-07 21:34 GMT+04:00 Zinovy Nis <<a href="mailto:zinovy.nis@gmail.com" target="_blank">zinovy.nis@gmail.com</a>>:<br><blockquote type="cite">Hi.<br><br>I attached a reduced sample, based on<br><a href="https://code.google.com/p/aobench/" target="_blank">https://code.google.com/p/aobench/</a>.<br><br>Run it first with an old SLP order:<br><br>1) clang -c -Ofast -static -march=core-avx2 aobench.cpp -Rpass=.<br>-mllvm -debug-only=loop-vectorize -mllvm<br>-run-slp-after-loop-vectorization=0<br><br>and then with a new order:<br><br>2) clang -c -Ofast -static -march=core-avx2 aobench.cpp -Rpass=.<br>-debug-only=loop-vectorize -mllvm<br>-run-slp-after-loop-vectorization=1<br><br>and see the logs:<br><br>1) aobench.cpp:59:9: remark: vectorized loop (vectorization<br>factor: 8,<br>unrolling interleave factor: 1) [-Rpass=loop-vectorize]<br>2) aobench.cpp:59:9: remark: loop ***not*** vectorized: use<br>-Rpass-analysis=loop-vectorize for more info<br>[-Rpass-missed=loop-vectorize]<br><br>LV: Found an unidentified PHI.  %occlusion.017 = phi float [<br>1.000000e+00, %entry ], [ %phitmp, %for.inc.for.body_crit_edge ]<br>LV: Can't vectorize the instructions or CFG<br>LV: Not vectorizing: Cannot prove legality.<br><br>2014-10-06 17:46 GMT+04:00 Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>:<br><blockquote type="cite">----- Original Message -----<br><blockquote type="cite">From: "Zinovy Nis" <<a href="mailto:zinovy.nis@gmail.com" target="_blank">zinovy.nis@gmail.com</a>><br>To: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>><br>Cc: "LLVM Commits" <<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>>, "Tobias Grosser"<br><<a href="mailto:tobias@grosser.es" target="_blank">tobias@grosser.es</a>>, "Chandler Carruth"<br><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>>, "Nadav Rotem" <<a href="mailto:nrotem@apple.com" target="_blank">nrotem@apple.com</a>>,<br>"Arnold Schwaighofer" <<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>><br>Sent: Monday, October 6, 2014 8:44:28 AM<br>Subject: Re: SLP/Loop vectorizer pass ordering<br><br>A bit later. At least GVN creates critical edges which are not<br>handled<br>by loop vectorizer then.<br></blockquote><br>Okay, please do (this is fairly important) -- if you can extract<br>some relevant IR, filing a bug report would be great. Are you<br>saying that running SLP early inhibits GVN from creating<br>critical edges that the loop vectorizer does not understand?<br><br>Thanks again,<br>Hal<br><br><blockquote type="cite"><br>2014-10-06 17:33 GMT+04:00 Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>:<br><blockquote type="cite">----- Original Message -----<br><blockquote type="cite">From: "Zinovy Nis" <<a href="mailto:zinovy.nis@gmail.com" target="_blank">zinovy.nis@gmail.com</a>><br>To: "Chandler Carruth" <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>><br>Cc: "LLVM Commits" <<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>>, "Tobias<br>Grosser"<br><<a href="mailto:tobias@grosser.es" target="_blank">tobias@grosser.es</a>><br>Sent: Monday, October 6, 2014 8:19:24 AM<br>Subject: Re: SLP/Loop vectorizer pass ordering<br><br>Please wait a while, I'm using it to revert the new order as<br>it<br>introduces regression in our internal benchmark: SLP was<br>creating<br>loop<br>vectorization opportunities when was called before LV. Now no<br>such<br>opportunities are available, so we've got a regression.<br></blockquote><br>Interesting. Can you provide any further details?<br><br>-Hal<br><br><blockquote type="cite"><br>2014-10-06 3:28 GMT+04:00 Chandler Carruth<br><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>>:<br><blockquote type="cite"><br>On Thu, Sep 4, 2014 at 6:32 AM, James Molloy<br><<a href="mailto:james@jamesmolloy.co.uk" target="_blank">james@jamesmolloy.co.uk</a>><br>wrote:<br><blockquote type="cite"><br>Hi Hal, Chandler,<br><br>r217144.<br></blockquote><br><br>Is anyone still using the option to disable this? If I don't<br>hear<br>anything,<br>I'll remove this option entirely in the next week.<br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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><br></blockquote>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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><br></blockquote><br>--<br>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<br></blockquote><br></blockquote><br>--<br>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<br></blockquote></blockquote></blockquote><br><br></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">--<span> </span></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Hal Finkel</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Assistant Computational Scientist</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Leadership Computing Facility</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Argonne National Laboratory</span></div></blockquote></div><br></div></blockquote></div>