<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Well, either removing that or implementing a mechanism to fully model this would resolve the issue.</div><div class="gmail_default" style="font-family:verdana,sans-serif">
If this is known to be widely broken the former would be the easiest to do, of course. Who should we consult on this, llvm-dev? Should I prepare a patch?</div><div class="gmail_default" style="font-family:verdana,sans-serif">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif">This impacts more than just vectorization, I can construct simple testcases where we fail to common scalar sqrt calls.</div><div class="gmail_default" style="font-family:verdana,sans-serif">
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 22, 2014 at 6:58 AM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">----- Original Message -----<br>
> From: "Raul Silvera" <<a href="mailto:rsilvera@google.com">rsilvera@google.com</a>><br>
> To: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>><br>
</div><div class="im">> Cc: "Nadav Rotem" <<a href="mailto:nrotem@apple.com">nrotem@apple.com</a>>, <a href="mailto:reviews%2BD2535%2Bpublic%2B071e8fd9238b048b@llvm-reviews.chandlerc.com">reviews+D2535+public+071e8fd9238b048b@llvm-reviews.chandlerc.com</a>, "Chandler<br>

> Carruth" <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>>, "llvm-commits" <<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a>><br>
> Sent: Tuesday, January 21, 2014 8:45:22 PM<br>
> Subject: Re: [PATCH] Enable SLP-vectorization of intrinsics.<br>
><br>
><br>
><br>
</div><div class="im">> I had a closer look trying to get a case to work vectorizing sqrt.<br>
> Unfortunately we fail to SLP vectorize even simple cases because the<br>
> sqrt intrinsic (as well as the other math-related intrinsics) are<br>
> marked as read-only, creating dependences with user stores.<br>
><br>
><br>
> I found the code in include/llvm/IR/Intrinsics.td where these<br>
> attributes are set, and there is a comment about them being treated<br>
> conservatively to model their dependence to hardware FP rounding<br>
> modes. This could be addressed by having a separate attribute to<br>
> model FP hardware settings (think of it as sqrt reading a specific<br>
> system memory location instead of reading all of user memory).<br>
><br>
><br>
> Has something like that been considered in the past, or is there a<br>
> different long-term strategy for dealing with these implicit<br>
> dependences?<br>
<br>
</div>To be honest, I'm not exactly sure why we both modeling this at all. Clang/LLVM have a stated policy of not supporting floating-point environment access (#pragma STDC FENV_ACCESS ON is not supported -- Clang will complain if you try). Our modeling of these things is explicitly broken in other respects.<br>

<span class="HOEnZb"><font color="#888888"><br>
 -Hal<br>
</font></span><div class="im HOEnZb"><br>
><br>
><br>
> If I manually remove the attribute we do SLP-vectorize a simple case<br>
> and seem to get the expected speedups from using vector sqrt<br>
> instructions.<br>
><br>
><br>
><br>
> On Fri, Jan 17, 2014 at 12:41 PM, Hal Finkel < <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> ><br>
> wrote:<br>
><br>
><br>
><br>
> ----- Original Message -----<br>
> > From: "Nadav Rotem" < <a href="mailto:nrotem@apple.com">nrotem@apple.com</a> ><br>
><br>
> > To: "Hal Finkel" < <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> ><br>
> > Cc:<br>
> > <a href="mailto:reviews%2BD2535%2Bpublic%2B071e8fd9238b048b@llvm-reviews.chandlerc.com">reviews+D2535+public+071e8fd9238b048b@llvm-reviews.chandlerc.com</a> ,<br>
> > <a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a> , <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a> ,<br>
> > <a href="mailto:rsilvera@google.com">rsilvera@google.com</a><br>
> > Sent: Friday, January 17, 2014 2:18:53 PM<br>
> > Subject: Re: [PATCH] Enable SLP-vectorization of intrinsics.<br>
> ><br>
><br>
> > I think that we are converting some functions to llvm intrinsics.<br>
> > Right?<br>
><br>
> Clang produces intrinsics for sqrt (only in fast-math mode), pow and<br>
> fma. I think that's it, and until you get to CodeGen, I don't think<br>
> we normally convert anything else at the LLVM level.<br>
><br>
> -Hal<br>
><br>
><br>
><br>
> ><br>
> > On Jan 17, 2014, at 12:11 PM, Hal Finkel < <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> > wrote:<br>
> ><br>
> > > ----- Original Message -----<br>
> > >> From: "Nadav Rotem" < <a href="mailto:nrotem@apple.com">nrotem@apple.com</a> ><br>
> > >> To: <a href="mailto:nrotem@apple.com">nrotem@apple.com</a> , <a href="mailto:rsilvera@google.com">rsilvera@google.com</a><br>
</div><div class="HOEnZb"><div class="h5">> > >> Cc: <a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a> , <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> > >> Sent: Friday, January 17, 2014 2:06:55 PM<br>
> > >> Subject: Re: [PATCH] Enable SLP-vectorization of intrinsics.<br>
> > >><br>
> > >><br>
> > >> The code looks great. I was wondering if you had a chance to run<br>
> > >> some performance tests on it. Does it catch anything in the LLVM<br>
> > >> test suite?<br>
> > ><br>
> > > Why do you expect it to catch anything in the test-suite until we<br>
> > > get the function calls too (just as we do in the loop<br>
> > > vectorizer)?<br>
> > ><br>
> > > -Hal<br>
> > ><br>
> > >><br>
> > >> <a href="http://llvm-reviews.chandlerc.com/D2535" target="_blank">http://llvm-reviews.chandlerc.com/D2535</a><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>
> > >><br>
> > ><br>
> > > --<br>
> > > Hal Finkel<br>
> > > Assistant Computational Scientist<br>
> > > Leadership Computing Facility<br>
> > > Argonne National Laboratory<br>
> ><br>
> ><br>
><br>
> --<br>
> Hal Finkel<br>
> Assistant Computational Scientist<br>
> Leadership Computing Facility<br>
> Argonne National Laboratory<br>
><br>
><br>
><br>
><br>
> --<br>
><br>
><br>
> Raúl E. Silvera<br>
><br>
><br>
<br>
--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div><font size="4" face="arial black, sans-serif" style="background-color:rgb(0,0,0)" color="#b45f06"> Raúl E. Silvera </font></div>
<div><br></div></div>
</div>