<div dir="ltr"><div dir="auto">I'm still not sure about this, for a few reasons:<div dir="auto"><br></div><div dir="auto">1) I'd like to try to treat epilogue loops the same way regardless of whether the main loop was vectorized by hand or automatically. So if someone hand-wrote an avx-512 16-wide loop, with alias checks, and we decide it's profitable to vectorize the epilogue loop by 4 and re-use the checks, it ought to be done the same way. I realize this may be a pipe-dream, though.</div><div dir="auto"><br></div><div dir="auto">2) I'm still somewhat worried about "tiny loops". As I wrote before, we explicitly refuse to vectorize loops we know have a trip-count less than 16, because our profitability heuristic for such loops is probably bad. IIUC the only reason we don't bail due to the threshold is because we use the same loop for "failed min iters check" and "failed alias check". So, because it's reachable through the alias-check path, the max trip count isn't actually known, even though the typical trip count is probably small. </div><div dir="auto">It's true that you currently don't try to vectorize the epilogue if the original VF is below 16, but this is a somewhat different condition. </div><div dir="auto"><br></div><div dir="auto">3) Technically speaking, constructing a new InnerLoopVectorizer to vectorize this one loop sounds weird. We already have a worklist in the vectorizer that's currently running.</div><div dir="auto"><br></div><div dir="auto">I don't think (1) is a blocker, and (3) should be easy to fix, but I'm not sure whether the way this is going to handle (2) is sufficient. If I'm the only one that this bothers, I won't stand in the way, but I'd like to at least make sure we've fully considered this.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 14, 2017 06:00, "Nema, Ashutosh" <<a href="mailto:Ashutosh.Nema@amd.com" target="_blank">Ashutosh.Nema@amd.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 lang="EN-US" link="blue" vlink="purple">
<div class="m_-8565914691181255471m_2339803851957541712WordSection1">
<p class="MsoNormal">Summarizing the discussion on the implementation approaches.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Discussed about two approaches, first running ‘InnerLoopVectorizer’ again on the epilog loop immediately after vectorizing the original loop within the same vectorization pass, the second approach where re-running vectorization pass and
limiting vectorization factor of epilog loop by metadata.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><Approach-2><u></u><u></u></p>
<p class="MsoNormal">Challenges with re-running the vectorizer pass:<u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph"><u></u><span>1)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Reusing alias check result: <u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph">When vectorizer pass runs again it finds the epilog loop as a new loop and it may generates alias check, this new alias check may overkill the gains of epilog vectorization.<u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph">We should use the already computed alias check result instead of re computing again.<u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph"><u></u><span>2)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Rerun the vectorizer and hoist the new alias check:<u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph">It’s not possible to hoist alias checks as its not fully redundant (not dominated by other checks), it’s not getting execute in all paths.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><img width="567" height="156" id="m_-8565914691181255471m_2339803851957541712Picture_x0020_1" src="cid:image003.jpg@01D29CF1.122287F0"><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">NOTE: We cannot prepone alias check as its expensive compared to other checks.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><Approach-1><u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph"><u></u><span>1)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Current patch depends on the existing functionality of LoopVectorizer, it uses ‘InnerLoopVectorizer’ again to vectorize the epilog loop, as it happens in the same vectorization pass we have flexibility to reuse already computed alias
result check & limit vectorization factor for the epilog loop. <u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph"><u></u><span>2)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>It does not generate the blocks for new block layout explicitly, rather it depends on ‘InnerLoopVectorizer::createEm<wbr>ptyLoop’ to generate new block layout. The new block layout get automatically generated by calling the ‘InnerLoopVectorizer::
vectorize’ again.<u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph"><u></u><span>3)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Block layout description with epilog loop vectorization is available at<u></u><u></u></p>
<p class="m_-8565914691181255471m_2339803851957541712MsoListParagraph"><a href="https://reviews.llvm.org/file/data/fxg5vx3capyj257rrn5j/PHID-FILE-x6thnbf6ub55ep5yhalu/LayoutDescription.png" target="_blank">https://reviews.llvm.org/file/<wbr>data/fxg5vx3capyj257rrn5j/PHID<wbr>-FILE-x6thnbf6ub55ep5yhalu/Lay<wbr>outDescription.png</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Approach-1 looks feasible, please comment if any objections.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Regards,<u></u><u></u></p>
<p class="MsoNormal">Ashutosh<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Nema, Ashutosh
<br>
<b>Sent:</b> Wednesday, March 1, 2017 10:42 AM<br>
<b>To:</b> 'Daniel Berlin' <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>><br>
<b>Cc:</b> <a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>; Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>; Zaks, Ayal <<a href="mailto:ayal.zaks@intel.com" target="_blank">ayal.zaks@intel.com</a>>; Renato Golin <<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>>; <a href="mailto:mkuper@google.com" target="_blank">mkuper@google.com</a>; Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> RE: [llvm-dev] [Proposal][RFC] Epilog loop vectorization<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Sorry I misunderstood, gvn/newgvn/gvnhoist cannot help here as these checks are not dominated by all paths.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Regards,<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Ashutosh<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:1.0in"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Daniel Berlin [<a href="mailto:dberlin@dberlin.org" target="_blank">mailto:dberlin@dberlin.org</a>]
<br>
<b>Sent:</b> Tuesday, February 28, 2017 6:58 PM<br>
<b>To:</b> Nema, Ashutosh <<a href="mailto:Ashutosh.Nema@amd.com" target="_blank">Ashutosh.Nema@amd.com</a>><br>
<b>Cc:</b> <a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>; Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>; Zaks, Ayal <<a href="mailto:ayal.zaks@intel.com" target="_blank">ayal.zaks@intel.com</a>>; Renato Golin <<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>>;
<a href="mailto:mkuper@google.com" target="_blank">mkuper@google.com</a>; Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] [Proposal][RFC] Epilog loop vectorization<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.0in">Hoisting or removing?<br>
Neither pass does hoisting, you'd need gvnhoist for that.<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">Even then:<br>
Staring at your example, none of the checks are fully redundant (IE they are not dominated by other checks) or execute on all paths.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">Thus, hoisting them would be purely speculative code motion, which none of our passes do.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">If you would like these sets of checks to be removed, you would need to place them in a place that they execute unconditionally.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">Otherwise, this is not a standard code hoisting/removal transform.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">The only redundancy i can see here at all is the repeated getelementptr computation.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">If you move it to the preheader, it will be eliminated.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">Otherwise, none of the checks are redundant.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><br>
What would you hope to happen in this case?<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.0in">On Tue, Feb 28, 2017 at 5:09 AM, Nema, Ashutosh <<a href="mailto:Ashutosh.Nema@amd.com" target="_blank">Ashutosh.Nema@amd.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I have tried running both gvn and newgvn but it did not helped in hoisting the alias checks:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Please check, maybe I have missed something.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><TestCase></span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">void foo (char *A, char *B, char *C, int len) {</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> int i = 0;</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> for (i=0 ; i< len; i++)</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> A[i] = B[i] + C[i];</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">}</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><Command></span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> $ opt –O3 –gvn test.ll –o test.opt.ll</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> $ opt –O3 –newgvn test.ll –o test.opt.ll</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">“test.ll” is attached, it got already vectorized by the approach running vectorizer twice by annotate the remainder loop with metadata to limit the vectorization factor for epilog
vector loop.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Regards,</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Ashutosh</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.0in">
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:1.5in">
<b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a> [mailto:<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>]
<br>
<b>Sent:</b> Tuesday, February 28, 2017 1:33 AM<br>
<b>To:</b> Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>><br>
<b>Cc:</b> Daniel Berlin <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>>; Nema, Ashutosh <<a href="mailto:Ashutosh.Nema@amd.com" target="_blank">Ashutosh.Nema@amd.com</a>>; Zaks, Ayal <<a href="mailto:ayal.zaks@intel.com" target="_blank">ayal.zaks@intel.com</a>>;
Renato Golin <<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>>;
<a href="mailto:mkuper@google.com" target="_blank">mkuper@google.com</a>; Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] [Proposal][RFC] Epilog loop vectorization</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On Feb 27, 2017, at 12:01 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On 02/27/2017 01:47 PM, Daniel Berlin wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On Mon, Feb 27, 2017 at 11:29 AM, Adam Nemet <<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On Feb 27, 2017, at 10:11 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On 02/27/2017 11:47 AM, Adam Nemet wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On Feb 27, 2017, at 9:39 AM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>> wrote:<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On Mon, Feb 27, 2017 at 9:29 AM, Adam Nemet <<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:1.5in">
On Feb 27, 2017, at 7:27 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif"><br>
On 02/27/2017 06:29 AM, Nema, Ashutosh wrote:</span><u></u><u></u></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt;font-variant-caps:normal;text-align:start;word-spacing:0px">
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif">Thanks for looking into this.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif">1) Issues with re running vectorizer:</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif">Vectorizer might generate redundant alias checks while vectorizing epilog loop.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif">Redundant alias checks are expensive, we like to reuse the results of already computed alias checks.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif">With metadata we can limit the width of epilog loop, but not sure about reusing alias check result.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in;background:white">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif">Any thoughts on rerunning vectorizer with reusing the alias check result ?</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<p class="MsoNormal" style="margin-left:1.5in">
<span style="font-size:7.5pt;font-family:"Helvetica",sans-serif"><br>
<span style="background:white">One way of looking at this is: Reusing the alias-check result is really just a conditional propagation problem; if we don't already have an optimization that can combine these after the fact, then we should.</span></span><u></u><u></u></p>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
+Danny<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
Isn’t Extended SSA supposed to help with this?<u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
Yes, it will solve this with no issue already. GVN probably does already too.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
even if if you have<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
if (a == b)<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
if (a == c)<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
if (a == d)<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
if (a == e)<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
if (a == g)<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
and we can prove a ... g equivalent, newgvn will eliminate them all and set all the branches true.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
If you need a simpler clean up pass, we could run it on sub-graphs.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
Yes we probably don’t want to run a full GVN after the “loop-scheduling” passes.<u></u><u></u></p>
</div>
</div>
</blockquote>
<p class="MsoNormal" style="margin-left:1.5in">
<br>
FWIW, we could, just without the memory-dependence analysis enabled (i.e. set the NoLoads constructor parameter to true). GVN is pretty fast in that mode.<u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
OK. Another data point is that I’ve seen cases in the past where the alias checks required for the loop passes could enable GVN to remove redundant loads/stores. Currently we can only pick these up with LTO when GVN is rerun.<u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
This is just GVN brokenness, newgvn should not have this problem.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
If it does, i'd love to see it.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal" style="margin-left:1.5in">
<br>
I thought that the problem is that we just don't run GVN after that point in the pipeline.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
Yeah, that is the problem but I think Danny misunderstood what I was trying to say.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
This was a datapoint to possibly rerun GVN with memory-awareness.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.5in">
<u></u> <u></u></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.5in">
<br>
-Hal<u></u><u></u></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
(I'm working on the last few parts of turning it on by default, but it requires a new getModRefInfo interface to be able to get the last few testcases)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt;margin-left:1.5in">
<u></u> <u></u></p>
<pre style="margin-left:1.5in">-- <u></u><u></u></pre>
<pre style="margin-left:1.5in">Hal Finkel<u></u><u></u></pre>
<pre style="margin-left:1.5in">Lead, Compiler Technology and Programming Languages<u></u><u></u></pre>
<pre style="margin-left:1.5in">Leadership Computing Facility<u></u><u></u></pre>
<pre style="margin-left:1.5in">Argonne National Laboratory<u></u><u></u></pre>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-left:1.5in">
<u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:1.0in"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote></div></div>
</div>