<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 5/16/2017 6:30 AM, Sanjay Patel
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+wODivVETB7mogZf03V17KDE3Ecqh=rFDwdPzGvn=PA5X=pMA@mail.gmail.com">
      <div dir="ltr">Thanks for posting this question, Julia.<br>
        <br>
        I had a similar question about a signed min/max variant here:<br>
        <a
href="http://lists.llvm.org/pipermail/llvm-dev/2016-November/106868.html"
          moz-do-not-send="true">http://lists.llvm.org/pipermail/llvm-dev/2016-November/106868.html</a><br>
        <br>
        The 2nd version in each case contains a canonical max/min
        representation in IR, and this could enable more IR analysis. <br>
        A secondary advantage is that the backend recognizes the max/min
        in the second IR form when creating DAG nodes, <br>
        and this directly affects isel for many targets.<br>
      </div>
    </blockquote>
    <br>
    This seems important.  And pattern-matching max(x,y)-y to a
    saturating subtract seems easy in the backend.<br>
    <br>
    <blockquote type="cite"
cite="mid:CA+wODivVETB7mogZf03V17KDE3Ecqh=rFDwdPzGvn=PA5X=pMA@mail.gmail.com">
      <div dir="ltr">A possibly important difference between the earlier
        example and the current unsigned case: <br>
        is a select with a zero constant operand easier to reason about
        in IR than the canonical min/max?<br>
      </div>
    </blockquote>
    <br>
    It might be in some cases... maybe?  I mean, it might be easier to
    analyze in ComputeMaskedBits or something, but we don't really do
    much to optimize selects involving zero.<br>
    <br>
    -Eli<br>
    <br>
    <blockquote type="cite"
cite="mid:CA+wODivVETB7mogZf03V17KDE3Ecqh=rFDwdPzGvn=PA5X=pMA@mail.gmail.com">
      <div class="gmail_extra">
        <div class="gmail_quote">On Tue, May 16, 2017 at 5:30 AM, Koval,
          Julia <span dir="ltr"><<a
              href="mailto:julia.koval@intel.com" target="_blank"
              moz-do-not-send="true">julia.koval@intel.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            (1.16)<br>
            %cmp = icmp ugt i16 %x, %y<br>
            %sub2 = sub i16 %y, %x<br>
            %res = select i1 %cmp, i16 0, i16 %sub2<br>
            <br>
            or<br>
            <br>
            (2.16)<br>
            %cmp = icmp ugt i16 %x, %y<br>
            %sel = select i1 %cmp, i16 %x, i16 %y<br>
            %sub = sub i16 %sel, %x<br>
            <br>
            Which of these versions is canonical? I think first version
            is better, because it can be converted to unsigned
            saturation instruction(i.e. PSUBUS), using existing backend
            code.<br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </body>
</html>