<div dir="ltr"><div><a href="http://llvm.org/bugs/show_bug.cgi?id=17713">http://llvm.org/bugs/show_bug.cgi?id=17713</a> shows another case where some kind of FP value tracking would be useful.<br><br></div>gcc can transform this division into multiplication by reciprocal:<br><pre class="" id="comment_text_0"> if (y == 2.0) return x/y;</pre><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 12:02 PM, 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"><span class="">----- Original Message -----<br>
> From: "Arch Robison" <<a href="mailto:arch.robison@intel.com">arch.robison@intel.com</a>><br>
> To: "Philip Reames" <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>>, <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
> Sent: Thursday, January 8, 2015 12:54:32 PM<br>
> Subject: Re: [LLVMdev] Floating-point range checks<br>
><br>
><br>
</span><span class="">> Thanks for the pointers. Looks like LazyValueInfo has the sort of<br>
> infrastructure I had in mind. LVILatticeVal could be extended to<br>
> floating point. (The comment “this can be made a lot more rich in<br>
> the future” is an invitation :-). I’m thinking a simple lattice<br>
> would address most cases of interest for floating-point checks. The<br>
> lattice points for floating-point could be all subsets of the<br>
> eight-element set:<br>
><br>
> {-inf,<0,-0,+0,>0,+inf,-nan,+nan},<br>
><br>
> where <0 and >0 denote finite negative/positive numbers respectively.<br>
><br>
<br>
</span>I'm not sure. Checks against 1.0 are also common. Why not just add a FP range class, like our constant range, and go from there?<br>
<br>
-Hal<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
><br>
> - Arch<br>
><br>
><br>
><br>
><br>
><br>
> From: Philip Reames [mailto:<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>]<br>
> Sent: Wednesday, January 7, 2015 6:03 PM<br>
> To: Robison, Arch; <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
> Subject: Re: [LLVMdev] Floating-point range checks<br>
><br>
><br>
><br>
> I don't believe we have much in this area currently.<br>
><br>
> Generally, something like this would existing in InstCombine and<br>
> ValueTracking.<br>
><br>
> Take a look at ComputeSignBit in ValueTracking.cpp. This doesn't<br>
> apply (?) to floating point numbers, but we'd need something<br>
> equivalent for them. It looks like there may already be a start in<br>
> the form of:<br>
> CannotBeNegativeZero<br>
><br>
> Other places to look would be SimplifyFAdd and<br>
> InstCombine::visitFAdd.<br>
><br>
> For this particular example, you're probably going to want a pattern<br>
> in SimplifyFCmp of the form:<br>
> matcher: sqrt_call( fadd(Value(X), SpecificValue(X)), fadd(Value(Y),<br>
> SpecificValue(Y)))<br>
> && CannotBeNegativeZero(X) && CannotBeNegativeZero(Y)<br>
><br>
> You might also look at LazyValueInfo, but that's probably of<br>
> secondary interest. It's purely in terms of constant integer ranges<br>
> currently.<br>
><br>
> Philip<br>
><br>
><br>
><br>
><br>
><br>
> On 01/07/2015 02:13 PM, Robison, Arch wrote:<br>
><br>
><br>
><br>
><br>
> The Julia language implements sqrt(x) with conditional branch taken<br>
> if x<0. Alas this prevents vectorization of loops with sqrt. Often<br>
> the argument can be proven to be non-negative. E.g., sqrt(x*x+y*y).<br>
> Is there an existing LLVM pass or analysis that does floating-point<br>
> range propagation to eliminate such unnecessary checks?<br>
><br>
><br>
><br>
><br>
><br>
> Arch D. Robison<br>
><br>
><br>
> Intel Corporation<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> _______________________________________________ LLVM Developers<br>
> mailing list <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>