<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 8, 2013, at 2:35 PM, Michael Ilseman <<a href="mailto:milseman@apple.com">milseman@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Point #1 makes sense to me.<div><br></div><div>For point #2, wouldn't that be somewhat orthogonal to the discussion, as it has/needs no knowledge that an IR-level transformation happened? Also, reciprocal-multiply will be the preferred option for many (most) backends if the IR says to do that. But, I suppose some backend might want to be allowed to do the reverse transformation if allowed by fast-math flags in IR, or fast-math mode in selection DAG.<div><br></div></div></div></blockquote><div><br></div><div>Oh, I forgot about optimize-for-size, which might be a user who desires the reverse transformation.</div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div>On Aug 8, 2013, at 2:23 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 8, 2013 at 2:07 PM, Chad Rosier <span dir="ltr"><<a href="mailto:chad.rosier@gmail.com" target="_blank" class="cremed">chad.rosier@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 class="im">On Thu, Aug 8, 2013 at 1:56 PM, Mark Lacey <span dir="ltr"><<a href="mailto:mark.lacey@apple.com" target="_blank" class="cremed">mark.lacey@apple.com</a>></span> wrote:<br>
<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><div><div>On Aug 8, 2013, at 9:56 AM, Jim Grosbach <<a href="mailto:grosbach@apple.com" target="_blank" class="cremed">grosbach@apple.com</a>> wrote:</div><br><blockquote type="cite">

<div style="word-wrap:break-word">Hi Chad,<div><br></div><div>This is a great transform to do, but you’re right that it’s only safe under fast-math. This is particularly interesting when the original divisor is a constant so you can materialize the reciprocal at compile-time. You’re right that in either case, this optimization should only kick in when there is more than one divide instruction that will be changed to a mul.</div>

</div></blockquote><div><br></div></div><div>It can be worthwhile to do this even in the case where there is only a single divide since 1/Y might be loop invariant, and could then be hoisted out later by LICM. You just need to be able to fold it back together when there is only a single use, and that use is not inside a more deeply nested loop.<br>

</div></div></div></blockquote></div><div><br>Ben's patch does exactly this, so perhaps that is the right approach.</div></blockquote></div><br>Just to be clear of what is being proposed (which I rather like):</div><div class="gmail_extra">
<br></div><div class="gmail_extra">1) Canonical form is to use the reciprocal when allowed (by the fast math flags, whichever we decide are appropriate).</div><div class="gmail_extra">2) The backend folds a single-use reciprocal into a direct divide.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Did I get it right? If so, I think this is a really nice way to capture all of the potential benefits of forming reciprocals without pessimizing code where it isn't helpful.</div>
</div>
_______________________________________________<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/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></div></div></blockquote></div><br></body></html>