<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hm, the binop and unop cases are new since I'd last looked. 
      That's actually what I had in mind, so request satisfied.  :)</p>
    <p>If you want to handle the intrinsics, that might be reasonable,
      but it was beyond what I was thinking.</p>
    <p>Philip<br>
    </p>
    <div class="moz-cite-prefix">On 6/16/21 9:18 AM, Sanjay Patel wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+wODivv0ERmbesVosz06V6JqhToHfNa8=Y3QC-jh6HE+U+4DA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Sure, I can do that. Make sure I'm not missing any corner
          cases: we already do the right thing for the regular FP
          opcodes via checks for BinaryOperator / UnaryOperator, but we
          miss all FP intrinsics currently?</div>
        <div><br>
        </div>
        <div>Started adding tests here:</div>
        <div><a
href="https://github.com/llvm/llvm-project/commit/572e506b55f0ad181ddbb04d889651caa5a287e8"
            moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/572e506b55f0ad181ddbb04d889651caa5a287e8</a></div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Jun 16, 2021 at 11:40
          AM Philip Reames <<a
            href="mailto:listmail@philipreames.com" target="_blank"
            moz-do-not-send="true">listmail@philipreames.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">This
          is long overdue.  Thanks.  :)<br>
          <br>
          Can I ask you to also update propagatesPoison in
          ValueTracking?<br>
          <br>
          Philip<br>
          <br>
          On 6/16/21 8:33 AM, Sanjay Patel via llvm-commits wrote:<br>
          > Author: Sanjay Patel<br>
          > Date: 2021-06-16T11:31:58-04:00<br>
          > New Revision: ce95200b7942bb0683fd491800bbd9e1dc908e04<br>
          ><br>
          > URL: <a
href="https://github.com/llvm/llvm-project/commit/ce95200b7942bb0683fd491800bbd9e1dc908e04"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/ce95200b7942bb0683fd491800bbd9e1dc908e04</a><br>
          > DIFF: <a
href="https://github.com/llvm/llvm-project/commit/ce95200b7942bb0683fd491800bbd9e1dc908e04.diff"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/ce95200b7942bb0683fd491800bbd9e1dc908e04.diff</a><br>
          ><br>
          > LOG: [InstSimplify] propagate poison through FP ops<br>
          ><br>
          > We already have this fold:<br>
          >    fadd float poison, 1.0 --> poison<br>
          > ...via ConstantFolding, so this makes the behavior
          consistent<br>
          > if the other operand(s) are non-constant.<br>
          ><br>
          > The fold for undef was added before poison existed as a<br>
          > value/type in IR.<br>
          ><br>
          > This came up in D102673 / D103169<br>
          > because we're trying to sort out the more complicated
          handling<br>
          > for constrained math ops.<br>
          > We should have the handling for the regular instructions
          done<br>
          > first, so we can build on that (or diverge as needed).<br>
          ><br>
          > Differential Revision: <a
            href="https://reviews.llvm.org/D104383" rel="noreferrer"
            target="_blank" moz-do-not-send="true">https://reviews.llvm.org/D104383</a><br>
          ><br>
          > Added:<br>
          >      <br>
          ><br>
          > Modified:<br>
          >      llvm/lib/Analysis/InstructionSimplify.cpp<br>
          >      llvm/test/Transforms/InstSimplify/call.ll<br>
          >      llvm/test/Transforms/InstSimplify/fp-undef-poison.ll<br>
          ><br>
          > Removed:<br>
          >      <br>
          ><br>
          ><br>
          >
################################################################################<br>
          > diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp
          b/llvm/lib/Analysis/InstructionSimplify.cpp<br>
          > index 7fb7a394e86ab..895218bea9f33 100644<br>
          > --- a/llvm/lib/Analysis/InstructionSimplify.cpp<br>
          > +++ b/llvm/lib/Analysis/InstructionSimplify.cpp<br>
          > @@ -4807,12 +4807,16 @@ static Constant
          *propagateNaN(Constant *In) {<br>
          >   }<br>
          >   <br>
          >   /// Perform folds that are common to any floating-point
          operation. This implies<br>
          > -/// transforms based on undef/NaN because the operation
          itself makes no<br>
          > +/// transforms based on poison/undef/NaN because the
          operation itself makes no<br>
          >   ///<br>
          > diff erence to the result.<br>
          > -static Constant *simplifyFPOp(ArrayRef<Value *>
          Ops,<br>
          > -                              FastMathFlags FMF,<br>
          > +static Constant *simplifyFPOp(ArrayRef<Value *>
          Ops, FastMathFlags FMF,<br>
          >                                 const SimplifyQuery
          &Q) {<br>
          >     for (Value *V : Ops) {<br>
          > +    // Poison is independent of anything else. It always
          propagates from an<br>
          > +    // operand to a math result.<br>
          > +    if (match(V, m_Poison()))<br>
          > +      return PoisonValue::get(V->getType());<br>
          > +<br>
          >       bool IsNan = match(V, m_NaN());<br>
          >       bool IsInf = match(V, m_Inf());<br>
          >       bool IsUndef = Q.isUndefValue(V);<br>
          ><br>
          > diff  --git a/llvm/test/Transforms/InstSimplify/call.ll
          b/llvm/test/Transforms/InstSimplify/call.ll<br>
          > index 99a4a96d33b1a..721f4941e5110 100644<br>
          > --- a/llvm/test/Transforms/InstSimplify/call.ll<br>
          > +++ b/llvm/test/Transforms/InstSimplify/call.ll<br>
          > @@ -953,7 +953,7 @@ define double @fma_undef_op0(double
          %x, double %y) {<br>
          >   <br>
          >   define double @fma_poison_op0(double %x, double %y) {<br>
          >   ; CHECK-LABEL: @fma_poison_op0(<br>
          > -; CHECK-NEXT:    ret double 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret double poison<br>
          >   ;<br>
          >     %r = call double @llvm.fma.f64(double poison, double
          %x, double %y)<br>
          >     ret double %r<br>
          > @@ -969,7 +969,7 @@ define double @fma_undef_op1(double
          %x, double %y) {<br>
          >   <br>
          >   define double @fma_poison_op1(double %x, double %y) {<br>
          >   ; CHECK-LABEL: @fma_poison_op1(<br>
          > -; CHECK-NEXT:    ret double 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret double poison<br>
          >   ;<br>
          >     %r = call double @llvm.fma.f64(double %x, double
          poison, double %y)<br>
          >     ret double %r<br>
          > @@ -985,7 +985,7 @@ define double @fma_undef_op2(double
          %x, double %y) {<br>
          >   <br>
          >   define double @fma_poison_op2(double %x, double %y) {<br>
          >   ; CHECK-LABEL: @fma_poison_op2(<br>
          > -; CHECK-NEXT:    ret double 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret double poison<br>
          >   ;<br>
          >     %r = call double @llvm.fma.f64(double %x, double %y,
          double poison)<br>
          >     ret double %r<br>
          > @@ -1001,7 +1001,7 @@ define double
          @fmuladd_undef_op0(double %x, double %y) {<br>
          >   <br>
          >   define double @fmuladd_poison_op0(double %x, double %y)
          {<br>
          >   ; CHECK-LABEL: @fmuladd_poison_op0(<br>
          > -; CHECK-NEXT:    ret double 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret double poison<br>
          >   ;<br>
          >     %r = call double @llvm.fmuladd.f64(double poison,
          double %x, double %y)<br>
          >     ret double %r<br>
          > @@ -1017,7 +1017,7 @@ define double
          @fmuladd_undef_op1(double %x, double %y) {<br>
          >   <br>
          >   define double @fmuladd_poison_op1(double %x, double %y)
          {<br>
          >   ; CHECK-LABEL: @fmuladd_poison_op1(<br>
          > -; CHECK-NEXT:    ret double 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret double poison<br>
          >   ;<br>
          >     %r = call double @llvm.fmuladd.f64(double %x, double
          poison, double %y)<br>
          >     ret double %r<br>
          > @@ -1033,7 +1033,7 @@ define double
          @fmuladd_undef_op2(double %x, double %y) {<br>
          >   <br>
          >   define double @fmuladd_poison_op2(double %x, double %y)
          {<br>
          >   ; CHECK-LABEL: @fmuladd_poison_op2(<br>
          > -; CHECK-NEXT:    ret double 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret double poison<br>
          >   ;<br>
          >     %r = call double @llvm.fmuladd.f64(double %x, double
          %y, double poison)<br>
          >     ret double %r<br>
          ><br>
          > diff  --git
          a/llvm/test/Transforms/InstSimplify/fp-undef-poison.ll
          b/llvm/test/Transforms/InstSimplify/fp-undef-poison.ll<br>
          > index 129d868704c46..6a8036c37b634 100644<br>
          > ---
          a/llvm/test/Transforms/InstSimplify/fp-undef-poison.ll<br>
          > +++
          b/llvm/test/Transforms/InstSimplify/fp-undef-poison.ll<br>
          > @@ -1,8 +1,6 @@<br>
          >   ; NOTE: Assertions have been autogenerated by
          utils/update_test_checks.py<br>
          >   ; RUN: opt < %s -instsimplify -S | FileCheck %s<br>
          >   <br>
          > -; TODO: the instructions with poison operands should
          return poison<br>
          > -<br>
          >   define float @fadd_undef_op0(float %x) {<br>
          >   ; CHECK-LABEL: @fadd_undef_op0(<br>
          >   ; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > @@ -13,7 +11,7 @@ define float @fadd_undef_op0(float %x)
          {<br>
          >   <br>
          >   define float @fadd_poison_op0(float %x) {<br>
          >   ; CHECK-LABEL: @fadd_poison_op0(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fadd float poison, %x<br>
          >     ret float %r<br>
          > @@ -29,7 +27,7 @@ define float @fadd_undef_op1(float %x)
          {<br>
          >   <br>
          >   define float @fadd_poison_op1(float %x) {<br>
          >   ; CHECK-LABEL: @fadd_poison_op1(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fadd float %x, poison<br>
          >     ret float %r<br>
          > @@ -45,7 +43,7 @@ define float @fsub_undef_op0(float %x)
          {<br>
          >   <br>
          >   define float @fsub_poison_op0(float %x) {<br>
          >   ; CHECK-LABEL: @fsub_poison_op0(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fsub float poison, %x<br>
          >     ret float %r<br>
          > @@ -61,7 +59,7 @@ define float @fsub_undef_op1(float %x)
          {<br>
          >   <br>
          >   define float @fsub_poison_op1(float %x) {<br>
          >   ; CHECK-LABEL: @fsub_poison_op1(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fsub float %x, poison<br>
          >     ret float %r<br>
          > @@ -77,7 +75,7 @@ define float @fmul_undef_op0(float %x)
          {<br>
          >   <br>
          >   define float @fmul_poison_op0(float %x) {<br>
          >   ; CHECK-LABEL: @fmul_poison_op0(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fmul float poison, %x<br>
          >     ret float %r<br>
          > @@ -93,7 +91,7 @@ define float @fmul_undef_op1(float %x)
          {<br>
          >   <br>
          >   define float @fmul_poison_op1(float %x) {<br>
          >   ; CHECK-LABEL: @fmul_poison_op1(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fmul float %x, poison<br>
          >     ret float %r<br>
          > @@ -109,7 +107,7 @@ define float @fdiv_undef_op0(float
          %x) {<br>
          >   <br>
          >   define float @fdiv_poison_op0(float %x) {<br>
          >   ; CHECK-LABEL: @fdiv_poison_op0(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fdiv float poison, %x<br>
          >     ret float %r<br>
          > @@ -125,7 +123,7 @@ define float @fdiv_undef_op1(float
          %x) {<br>
          >   <br>
          >   define float @fdiv_poison_op1(float %x) {<br>
          >   ; CHECK-LABEL: @fdiv_poison_op1(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = fdiv float %x, poison<br>
          >     ret float %r<br>
          > @@ -141,7 +139,7 @@ define float @frem_undef_op0(float
          %x) {<br>
          >   <br>
          >   define float @frem_poison_op0(float %x) {<br>
          >   ; CHECK-LABEL: @frem_poison_op0(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = frem float poison, %x<br>
          >     ret float %r<br>
          > @@ -157,7 +155,7 @@ define float @frem_undef_op1(float
          %x) {<br>
          >   <br>
          >   define float @frem_poison_op1(float %x) {<br>
          >   ; CHECK-LABEL: @frem_poison_op1(<br>
          > -; CHECK-NEXT:    ret float 0x7FF8000000000000<br>
          > +; CHECK-NEXT:    ret float poison<br>
          >   ;<br>
          >     %r = frem float %x, poison<br>
          >     ret float %r<br>
          ><br>
          ><br>
          >          <br>
          > _______________________________________________<br>
          > llvm-commits mailing list<br>
          > <a href="mailto:llvm-commits@lists.llvm.org"
            target="_blank" moz-do-not-send="true">llvm-commits@lists.llvm.org</a><br>
          > <a
            href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>