<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Aren't disappearing bugs fun?  :)</p>
    <p>Skimming the thread, one thing we might want to consider is
      teaching the vectorizer how to widen an assume.  This would attack
      the problem from another angle.  <br>
    </p>
    <p>For any assume(X), if we unroll that as:<br>
      assume(X1)<br>
      assume(X2)<br>
      ....<br>
      assume(XN)</p>
    <p>We could also widen that into a single assume as:<br>
      %vec = {X1, X2, ..., XN)<br>
      %c = horizontal_and(%vec)<br>
      assume(%c)</p>
    <p>The catch is that I don't think we've considered whether we want
      this to be a canonical form or not.  For the vectorizer with %vec
      already existing, I think it makes good sense though.</p>
    <p>Philip<br>
    </p>
    <div class="moz-cite-prefix">On 4/29/21 12:42 PM, Sanjay Patel
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+wODivNjncGTG5dx7+rM9Dk=8eTm0JCBti1F2oqB3z6HWaL+A@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Ah - the degenerate case was based on:</div>
        <div><a href="https://bugs.llvm.org/show_bug.cgi?id=49785#c2"
            moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=49785#c2</a></div>
        <div><br>
        </div>
        <div>But I just reverted this locally:<br>
        </div>
        <div><a
href="https://reviews.llvm.org/rGbb907b26e2bf2a0d5ea3fcb13ba0ccef3420a38c"
            moz-do-not-send="true">https://reviews.llvm.org/rGbb907b26e2bf2a0d5ea3fcb13ba0ccef3420a38c</a></div>
        <div><br>
        </div>
        <div>And neither the original C example from PR49785 nor the IR
          reduction are taking forever to compile for me. Something else
          must have changed in the past 2 weeks to mask the problem. So
          I'm not sure how to trigger this again.<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Apr 28, 2021 at 5:19
          PM Philip Reames <<a
            href="mailto:listmail@philipreames.com"
            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">
          <div>
            <p>Sanjay,</p>
            <p>Neither of these seem to be the degenerate test case you
              saw the compile time impact on.  Could you point me to
              that?  I'm looking for something to run to understand the
              compile time opportunities in this code.</p>
            <p>Philip<br>
            </p>
            <div>On 4/15/21 6:48 AM, Sanjay Patel wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div>I'm not understanding the question. 🤔<br>
                </div>
                <div><br>
                </div>
                <div>I suspect this doesn't answer it, but more of the
                  trail that led here:<br>
                </div>
                <div>There was a gap where isKnownNonEqual was
                  succeeding where simplifyICmpWithZero() did not - it
                  was plugged with:</div>
                <div><a
href="https://reviews.llvm.org/rG5ae5d25e38efad1d59ed97d969a5e930b58a5e16"
                    target="_blank" moz-do-not-send="true">https://reviews.llvm.org/rG5ae5d25e38efad1d59ed97d969a5e930b58a5e16</a></div>
                <div><br>
                </div>
                <div>That was exposed by this test (and that's what the
                  unittest in the above commit is based on):</div>
                <div><a
href="https://github.com/llvm/llvm-project/blob/9345f9fa5d6401bf9b98ce915bf4fbde9d183ce7/llvm/test/Analysis/ValueTracking/monotonic-phi.ll#L185"
                    target="_blank" moz-do-not-send="true">https://github.com/llvm/llvm-project/blob/9345f9fa5d6401bf9b98ce915bf4fbde9d183ce7/llvm/test/Analysis/ValueTracking/monotonic-phi.ll#L185</a></div>
                <div><br>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Wed, Apr 14, 2021
                  at 6:04 PM 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">Hm, this seems
                  interesting.<br>
                  <br>
                  I had been thinking about inverting this API by having
                  the shared code <br>
                  return the two pointers which imply
                  equality/inequality and having <br>
                  instcombine rewrite the condition.  However, I
                  couldn't find a case <br>
                  where the existing logic didn't already do that
                  inversion through some <br>
                  other (more general) path.  Do you happen to have an
                  IR fragment where <br>
                  we trip this example?  I'd like to take a look at it
                  with that lens.<br>
                  <br>
                  Philip<br>
                  <br>
                  On 4/14/21 6:12 AM, Sanjay Patel via llvm-commits
                  wrote:<br>
                  > Author: Sanjay Patel<br>
                  > Date: 2021-04-14T09:04:15-04:00<br>
                  > New Revision:
                  7ef2c68a3d24af0b0d540e748e8b564180f4e18a<br>
                  ><br>
                  > URL: <a
href="https://github.com/llvm/llvm-project/commit/7ef2c68a3d24af0b0d540e748e8b564180f4e18a"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/7ef2c68a3d24af0b0d540e748e8b564180f4e18a</a><br>
                  > DIFF: <a
href="https://github.com/llvm/llvm-project/commit/7ef2c68a3d24af0b0d540e748e8b564180f4e18a.diff"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/7ef2c68a3d24af0b0d540e748e8b564180f4e18a.diff</a><br>
                  ><br>
                  > LOG: [InstSimplify] improve efficiency for
                  detecting non-zero value<br>
                  ><br>
                  > Stepping through callstacks in the example from
                  D99759 reveals<br>
                  > this potential compile-time improvement.<br>
                  ><br>
                  > The savings come from avoiding ValueTracking's
                  computing known<br>
                  > bits if we have already dealt with special-case
                  patterns.<br>
                  ><br>
                  > Further improvements in this direction seem
                  possible.<br>
                  ><br>
                  > This makes a degenerate test based on PR49785
                  about 40x faster<br>
                  > (25 sec -> 0.6 sec), but it does not address
                  the larger question<br>
                  > of how to limit computeKnownBitsFromAssume(). Ie,
                  the original<br>
                  > test there is still infinite-time for all
                  practical purposes.<br>
                  ><br>
                  > Differential Revision: <a
                    href="https://reviews.llvm.org/D100408"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://reviews.llvm.org/D100408</a><br>
                  ><br>
                  > Added:<br>
                  >      <br>
                  ><br>
                  > Modified:<br>
                  >      llvm/lib/Analysis/InstructionSimplify.cpp<br>
                  ><br>
                  > Removed:<br>
                  >      <br>
                  ><br>
                  ><br>
                  >
################################################################################<br>
                  > diff  --git
                  a/llvm/lib/Analysis/InstructionSimplify.cpp
                  b/llvm/lib/Analysis/InstructionSimplify.cpp<br>
                  > index b233a0f3eb2d..08f504a0ce37 100644<br>
                  > --- a/llvm/lib/Analysis/InstructionSimplify.cpp<br>
                  > +++ b/llvm/lib/Analysis/InstructionSimplify.cpp<br>
                  > @@ -3432,6 +3432,8 @@ static Value
                  *SimplifyICmpInst(unsigned Predicate, Value *LHS,
                  Value *RHS,<br>
                  >     if (Value *V = simplifyICmpOfBools(Pred, LHS,
                  RHS, Q))<br>
                  >       return V;<br>
                  >   <br>
                  > +  // TODO: Sink/common this with other
                  potentially expensive calls that use<br>
                  > +  //       ValueTracking? See comment below for
                  isKnownNonEqual().<br>
                  >     if (Value *V = simplifyICmpWithZero(Pred,
                  LHS, RHS, Q))<br>
                  >       return V;<br>
                  >   <br>
                  > @@ -3637,7 +3639,9 @@ static Value
                  *SimplifyICmpInst(unsigned Predicate, Value *LHS,
                  Value *RHS,<br>
                  >     }<br>
                  >   <br>
                  >     // icmp eq|ne X, Y -> false|true if X != Y<br>
                  > -  if (ICmpInst::isEquality(Pred) &&<br>
                  > +  // This is potentially expensive, and we have
                  already computedKnownBits for<br>
                  > +  // compares with 0 above here, so only try
                  this for a non-zero compare.<br>
                  > +  if (ICmpInst::isEquality(Pred) &&
                  !match(RHS, m_Zero()) &&<br>
                  >         isKnownNonEqual(LHS, RHS, Q.DL, <a
                    href="http://Q.AC" rel="noreferrer" target="_blank"
                    moz-do-not-send="true">Q.AC</a>, Q.CxtI, Q.DT,
                  Q.IIQ.UseInstrInfo)) {<br>
                  >       return Pred == ICmpInst::ICMP_NE ?
                  getTrue(ITy) : getFalse(ITy);<br>
                  >     }<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>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>