<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>I think there's two interacting pieces here:</p>
    <ul>
      <li>I don't believe we have a way to represent an assume at the MI
        layer.  If we let them flow through codegen, we'd need to add
        such a thing.</li>
      <li>The tradeoffs between information preservation and lowering
        may be different at different points in the pipeline.  Johannes
        frames this as a canonicalization problem.  That sounds
        reasonable, but it's also reasonable that we may need to give up
        on preserving assumes at some point.  (As a silly example, we
        probably don't want them at MC.)  Where exactly that point is
        unclear, and is mostly a matter of practical engineering
        tradeoffs.</li>
    </ul>
    <p>If you felt like exploring alternate lowering points, that would
      seem entirely reasonable.  It might not work out, or it might
      require a bunch of work to make happen, but the basic idea seems
      entirely worth exploring.</p>
    <p>Philip<br>
    </p>
    <div class="moz-cite-prefix">On 5/25/21 3:11 AM, Markus Lavin via
      llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:VI1PR07MB6128D928959865E760BD684CE8259@VI1PR07MB6128.eurprd07.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span lang="EN-US">With recent changes in
            BasicAA (mostly by Nikita Popov I believe) llvm.assumes can
            now guide in the AA decision making. Which is of course
            great.  <o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">For example for C input
            (or IR equivalent) as follows it can make a huge difference
            if the variable ‘x’ is known to be non-zero when AA is
            queried during scheduling<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">__builtin_assume(x !=
            0);<o:p></o:p></span></p>
        <p class="MsoNormal">for (int i = 0; i < 64; i += 4) {<o:p></o:p></p>
        <p class="MsoNormal">  v[(i + 0) * x] = v[(i + 0) * x] >>
          2;<o:p></o:p></p>
        <p class="MsoNormal">  v[(i + 1) * x] = v[(i + 1) * x] >>
          2;<o:p></o:p></p>
        <p class="MsoNormal">  v[(i + 2) * x] = v[(i + 2) * x] >>
          2;<o:p></o:p></p>
        <p class="MsoNormal">  <span lang="EN-US">v[(i + 3) * x] = v[(i
            + 3) * x] >> 2;<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">}<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Unfortunately it appears
            that the CodeGenPrepare pass removes llvm.assume so that
            they never reach the code generator. Currently commit
            91c9dee3fb6d89ab3 (and before that commit 6d20937c29a1a1d67)
            eliminate assumptions in CodeGenPrepare for reasons that
            appear to be optimization (avoiding blocks that would be
            empty if it was not for the llvm.assume and its
            predecessors).<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">It seems these two
            efforts are quite contradictory. Is there any deeper
            thinking behind this? I for one would be in favor of not
            eliminating assumes.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">-Markus<o:p></o:p></span></p>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
  </body>
</html>