<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Sanjay,<div class=""><br class=""></div><div class="">Except for memcpy, are there other examples where going from first class sequence of instructions to intrinsics is considered an OK canonicalization?<div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div><div class=""><br class=""><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Nov 19, 2016, at 8:40 PM, Sanjay Patel via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="white-space:pre-wrap" class="">The potential advantage I was considering would be more accurate cost modeling in the vectorizer, inliner, etc. Like min/max, this is another case where the sum of the IR parts is greater than the actual cost.<br class=""><br class="">Beyond that, it seems odd to me that we'd choose the longer IR expression of something that could be represented in a minimal form. I know we make practical concessions in IR based on backend deficiencies, but in this case I think the fix would be easy - if we're in contract=fast mode, just split all of these intrinsics at DAG creation time and let the DAG or other passes behave exactly like they do today to fuse them back together again?</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sat, Nov 19, 2016 at 8:29 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br class="gmail_msg">
> From: "Hal J. via llvm-dev Finkel" <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>><br class="gmail_msg">
> To: "Sanjay Patel" <<a href="mailto:spatel@rotateright.com" class="gmail_msg" target="_blank">spatel@rotateright.com</a>><br class="gmail_msg">
> Cc: "llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>><br class="gmail_msg">
> Sent: Saturday, November 19, 2016 10:58:27 AM<br class="gmail_msg">
> Subject: Re: [llvm-dev] FMA canonicalization in IR<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Sent from my Verizon Wireless 4G LTE DROID<br class="gmail_msg">
> On Nov 19, 2016 10:26 AM, Sanjay Patel < <a href="mailto:spatel@rotateright.com" class="gmail_msg" target="_blank">spatel@rotateright.com</a> ><br class="gmail_msg">
> wrote:<br class="gmail_msg">
> ><br class="gmail_msg">
> > If I have my FMA intrinsics story straight now (thanks for the<br class="gmail_msg">
> > explanation, Hal!), I think it raises another question about IR<br class="gmail_msg">
> > canonicalization (and may affect the proposed revision to IR FMF):<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> No, I think that we specifically don't want to canonicalize to<br class="gmail_msg">
> fmuladd at the IR level at all. If the backend has the freedom to<br class="gmail_msg">
> form FMAs as it sees fit, then we should delay the decision until<br class="gmail_msg">
> whenever the backend finds most appropriate. Some backends, for<br class="gmail_msg">
> example, form FMAs using the MachineCombiner pass which considers<br class="gmail_msg">
> critical path, latency, throughputs, etc. in order to find the best<br class="gmail_msg">
> fusion opportunities. We only use fmuladd when required to restrict<br class="gmail_msg">
> the backend to certain choices due to source-language semantics.<br class="gmail_msg">
<br class="gmail_msg">
I'll also add that, in general, we canonicalize in order to enable other transformations (and reduce the number of input forms those transformations need to match in order to be effective). Forming @llvm.fmulall at the IR level does not seem to further this goal. Did you have something in mind that this canonicalization would help?<br class="gmail_msg">
<br class="gmail_msg">
Thanks again,<br class="gmail_msg">
Hal<br class="gmail_msg">
<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Thanks again,<br class="gmail_msg">
> Hal<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> ><br class="gmail_msg">
> > define float @foo(float %a, float %b, float %c) {<br class="gmail_msg">
> > %mul = fmul fast float %a, %b ; using 'fast' because there is no<br class="gmail_msg">
> > 'fma' flag<br class="gmail_msg">
> > %add = fadd fast float %mul, %c<br class="gmail_msg">
> > ret float %add<br class="gmail_msg">
> > }<br class="gmail_msg">
> ><br class="gmail_msg">
> > Should this be:<br class="gmail_msg">
> ><br class="gmail_msg">
> > define float @goo(float %a, float %b, float %c) {<br class="gmail_msg">
> > % maybe.fma = call fast float @llvm.fmuladd.f32(float %a, float %b,<br class="gmail_msg">
> > float %c)<br class="gmail_msg">
> > ret float % maybe.fma<br class="gmail_msg">
> > }<br class="gmail_msg">
> > declare float @llvm.fmuladd.f32(float %a, float %b, float %c)<br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> LLVM Developers mailing list<br class="gmail_msg">
> <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Hal Finkel<br class="gmail_msg">
Lead, Compiler Technology and Programming Languages<br class="gmail_msg">
Leadership Computing Facility<br class="gmail_msg">
Argonne National Laboratory<br class="gmail_msg">
</blockquote></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></div></div></div></body></html>