<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>I'm going to mostly stay out of the floating point specifics, but
      I want to point out a few alternative approaches which have been
      used elsewhere in the past.</p>
    <p>We have the ability to require a intrinsic function argument to
      be a constant.  We have support for annotations printed during IR
      serialization.  Putting those together, we could use an argument
      encoding + annotation printer to field something like:</p>
    <p>%sum = call double @llvm.experimental.constrained.fadd(double %x,<br>
                                                             double %y,
      int 0, int 1) ;; fpround.dynamic + fpexcept.strict<br>
    </p>
    <p>If we didn't want to have token types involved, we could use
      operand bundles and a custom annotator.  We'd get something like:<br>
    </p>
     %sum = call double @llvm.experimental2.constrained.fadd(double %x,<br>
                                                            double %y) [
    “fenv”(i32 0, i32 1)] ;; fpround.dynamic + fpexcept.strict
    <p></end alternatives></p>
    <p>Personally, I'd try to avoid token types here.  Token types are
      relatively ill defined, and most of the cases we've used them have
      been a proxy for multiple variable return.  In retrospect, I wish
      we'd done multiple variable return e.g. statepoints.  <br>
    </p>
    <p>Philip<br>
    </p>
    <div class="moz-cite-prefix">On 11/14/19 11:39 AM, Kaylor, Andrew
      via llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:BYAPR11MB3109E88793A456B052288E20E8710@BYAPR11MB3109.namprd11.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 Definitions */
@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.nd
        {mso-style-name:nd;}
span.o
        {mso-style-name:o;}
span.n
        {mso-style-name:n;}
span.p
        {mso-style-name:p;}
span.nb
        {mso-style-name:nb;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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">Hello everyone,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I’ve just uploaded a patch (<a
            href="https://reviews.llvm.org/D70261"
            moz-do-not-send="true">https://reviews.llvm.org/D70261</a>)
          to introduce a could of new token types to be used with
          constrained floating point intrinsics and, optionally, vector
          predicated intrinsics. These intrinsics may not be of interest
          to many of you, but I have a more general question.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I would like some general feedback on the
          way I am proposing to use token arguments and operand bundles.
          I have an incomplete understanding of how these are intended
          to be used, and I want to make sure what I have in mind is
          consistent with the philosophy behind them.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Currently, the constrained floating point
          intrinsics require string metadata arguments to describe the
          rounding mode and exception semantics. These “arguments” are
          really providing information to the optimizer about what it
          can and cannot assume when acting on these intrinsics. The
          rounding mode argument potentially overrides the default
          optimizer assumption that the “to nearest” rounding mode is in
          use, and the exception behavior argument overrides the default
          optimizer assumption that floating point operations have no
          side effects. I’ve never liked the use of strings here, and
          the fact that these arguments are not actually inputs to the
          operation represented by the intrinsic seems vaguely wrong.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">A typical call to a current intrinsic looks
          like this:<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div style="mso-element:para-border-div;border:solid #CCCCCC
          1.0pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#F8F8F8">
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <b><span style="font-size:10.0pt;font-family:"Courier
                New";color:#555555">%sum = call double @llvm</span></b><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:#666666">.</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:black">experimental</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:#666666">.</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:black">constrained</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:#666666">.</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:black">fadd(double %x,<o:p></o:p></span></p>
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <span style="font-size:10.0pt;font-family:"Courier
              New";color:black">                                                      
              double %y,<o:p></o:p></span></p>
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <span style="font-size:10.0pt;font-family:"Courier
              New";color:black">                                                      
              Metadata “fpround.dynamic”,<o:p></o:p></span></p>
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <span style="font-size:10.0pt;font-family:"Courier
              New";color:black">                                                
                    Metadata “fpexcept.strict”)<o:p></o:p></span></p>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">The idea I am pursuing in my patch is to
          replace these metadata arguments with optional operand
          bundles, “fpround” and “fpexcept”. If the operand bundles are
          present, they would mean what the arguments currently mean. If
          not, the default assumption is allowed. A typical call to a
          constrained intrinsic would look like this:<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div style="mso-element:para-border-div;border:solid #CCCCCC
          1.0pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#F8F8F8">
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <b><span style="font-size:10.0pt;font-family:"Courier
                New";color:#555555">%sum = call double @llvm</span></b><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:#666666">.</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:black">experimental2</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:#666666">.</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:black">constrained</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:#666666">.</span><span
              style="font-size:10.0pt;font-family:"Courier
              New";color:black">fadd(double %x,<o:p></o:p></span></p>
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <span style="font-size:10.0pt;font-family:"Courier
              New";color:black">                                                      
               double %y) [ “fpround”(token rmDynamic),<o:p></o:p></span></p>
          <p class="MsoNormal"
            style="line-height:11.95pt;background:#F8F8F8;border:none;padding:0in">
            <span style="font-size:10.0pt;font-family:"Courier
              New";color:black">                                                
                                  “fpexcept”(token ebStrict) ]<o:p></o:p></span></p>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Does that seem like a valid use of tokens
          and operand bundles? Does it seem better than the current
          approach?<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Thanks,<o:p></o:p></p>
        <p class="MsoNormal">Andy<o:p></o:p></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>