<div dir="ltr"><div>For reference, the IR side of this was:</div><div><a href="https://reviews.llvm.org/D44308">https://reviews.llvm.org/D44308</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 7, 2020 at 1:01 PM Sanjay Patel <<a href="mailto:spatel@rotateright.com">spatel@rotateright.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">For reference, the IR side of this was:<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 7, 2020 at 12:30 PM Nuno Lopes via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It's not correct (output of Alive2):<br>
<br>
define half @fn(half %a) {<br>
   %b = fadd half %a, undef<br>
   ret half %b<br>
}<br>
=><br>
define half @fn(half %a) {<br>
   ret half undef<br>
}<br>
Transformation doesn't verify!<br>
ERROR: Value mismatch<br>
<br>
Example:<br>
half %a = #x0e02 (0.000366687774?)<br>
<br>
Source:<br>
half %b = NaN   [based on undef value]<br>
<br>
Target:<br>
Source value: NaN<br>
Target value: #x8000 (-0.0)<br>
<br>
<br>
Essentially, for some inputs, doing an operation with any value can't  <br>
produce some value, as the example above shows.<br>
<br>
Nuno<br>
<br>
<br>
<br>
Quoting Cameron McInally via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>:<br>
<br>
> I came across this comment in SelectionDAG.cpp:<br>
><br>
>   case ISD::FADD:<br>
>   case ISD::FSUB:<br>
>   case ISD::FMUL:<br>
>   case ISD::FDIV:<br>
>   case ISD::FREM:<br>
>     // If both operands are undef, the result is undef. If 1 operand  <br>
> is undef,<br>
>     // the result is NaN. This should match the behavior of the IR optimizer.<br>
><br>
> That isn't intuitive to me. I would have expected a binary FP<br>
> operation with one undef operand to fold to undef. Does anyone know<br>
> the reasoning behind that decision? I don't see the value added in<br>
> returning a NaN here.<br>
><br>
> Thx,<br>
> Cameron<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>