<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 01/23/2017 11:36 PM, Jonas Paulsson
      wrote:<br>
    </div>
    <blockquote
      cite="mid:9864f98b-06a8-fe45-529d-98cc45a981d1@linux.vnet.ibm.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Hi all,</p>
      <p>thanks!</p>
      <p>>  Not sure if it's described anywhere off the top of my
        head; if there isn't a comment describing this on the
        declaration of LowerOperation or LowerOperationWrapper, it would
        probably be good to add one.  Returning SDValue() should be
        "fine" in all cases (it might lead to a fatal error if we can't
        actually lower the operation). <br>
      </p>
      <p>Does this sound good?</p>
    </blockquote>
    <br>
    Why don't we just say, "Returning SDValue() indicates that the input
    node should be expanded."?<br>
    <br>
     -Hal<br>
    <br>
    <blockquote
      cite="mid:9864f98b-06a8-fe45-529d-98cc45a981d1@linux.vnet.ibm.com"
      type="cite">
      <p><tt>diff --git a/include/llvm/Target/TargetLowering.h
          b/include/llvm/Target/TargetLowering.h</tt><tt><br>
        </tt><tt>index 01c5c51..41edcc6 100644</tt><tt><br>
        </tt><tt>--- a/include/llvm/Target/TargetLowering.h</tt><tt><br>
        </tt><tt>+++ b/include/llvm/Target/TargetLowering.h</tt><tt><br>
        </tt><tt>@@ -2830,7 +2830,8 @@ public:</tt><tt><br>
        </tt><tt>   /// target, which are registered to use 'custom'
          lowering, and whose defined</tt><tt><br>
        </tt><tt>   /// values are all legal.  If the target has no
          operations that require custom</tt><tt><br>
        </tt><tt>   /// lowering, it need not implement this.  The
          default implementation of this</tt><tt><br>
        </tt><tt>-  /// aborts.</tt><tt><br>
        </tt><tt>+  /// aborts. Returning SDValue() is ok and signals
          that the input node</tt><tt><br>
        </tt><tt>+  /// should be further handled by the caller instead.</tt><tt><br>
        </tt><tt>   virtual SDValue LowerOperation(SDValue Op,
          SelectionDAG &DAG) const;</tt><tt><br>
        </tt><tt> </tt><tt><br>
        </tt><tt>   /// This callback is invoked when a node result type
          is illegal for the</tt><br>
      </p>
      <p>/ Jonas</p>
      <p><br>
      </p>
      <div class="moz-cite-prefix">On 2017-01-23 22:59, Hal Finkel via
        llvm-dev wrote:<br>
      </div>
      <blockquote
        cite="mid:2f40c5d7-d682-b174-e50a-de4e99152a4a@anl.gov"
        type="cite">
        <p><br>
        </p>
        <div class="moz-cite-prefix">On 01/23/2017 02:41 PM, Matt
          Arsenault via llvm-dev wrote:<br>
        </div>
        <blockquote
          cite="mid:755F29A7-F561-4FCD-A424-829A7B03141A@gmail.com"
          type="cite"> <br class="">
          <div>
            <blockquote type="cite" class="">
              <div class="">On Jan 23, 2017, at 12:36, Friedman, Eli via
                llvm-dev <<a moz-do-not-send="true"
                  href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>>
                wrote:</div>
              <br class="Apple-interchange-newline">
              <div class=""><span style="font-family: Helvetica;
                  font-size: 12px; font-style: normal;
                  font-variant-caps: normal; font-weight: normal;
                  letter-spacing: normal; orphans: auto; text-align:
                  start; text-indent: 0px; text-transform: none;
                  white-space: normal; widows: auto; word-spacing: 0px;
                  -webkit-text-stroke-width: 0px; float: none; display:
                  inline !important;" class="">On 1/23/2017 5:21 AM,
                  Jonas Paulsson wrote:</span><br style="font-family:
                  Helvetica; font-size: 12px; font-style: normal;
                  font-variant-caps: normal; font-weight: normal;
                  letter-spacing: normal; orphans: auto; text-align:
                  start; text-indent: 0px; text-transform: none;
                  white-space: normal; widows: auto; word-spacing: 0px;
                  -webkit-text-stroke-width: 0px;" class="">
                <blockquote type="cite" style="font-family: Helvetica;
                  font-size: 12px; font-style: normal;
                  font-variant-caps: normal; font-weight: normal;
                  letter-spacing: normal; orphans: auto; text-align:
                  start; text-indent: 0px; text-transform: none;
                  white-space: normal; widows: auto; word-spacing: 0px;
                  -webkit-text-size-adjust: auto;
                  -webkit-text-stroke-width: 0px;" class="">Hi Eli,<br
                    class="">
                  <br class="">
                  I would like to clarify generally what the difference
                  is between returning SDValue() and Op (input argument
                  unchanged) from LowerOperation()?<br class="">
                  <br class="">
                  My understanding is that returning SDValue() means
                  that Target gives up, and the common code is supposed
                  to handle it. Returning Op, the unchanged argument,
                  means that the Target is happy with the node as it is,
                  and the common code can move on to something else.<br
                    class="">
                </blockquote>
                <br style="font-family: Helvetica; font-size: 12px;
                  font-style: normal; font-variant-caps: normal;
                  font-weight: normal; letter-spacing: normal; orphans:
                  auto; text-align: start; text-indent: 0px;
                  text-transform: none; white-space: normal; widows:
                  auto; word-spacing: 0px; -webkit-text-stroke-width:
                  0px;" class="">
                <span style="font-family: Helvetica; font-size: 12px;
                  font-style: normal; font-variant-caps: normal;
                  font-weight: normal; letter-spacing: normal; orphans:
                  auto; text-align: start; text-indent: 0px;
                  text-transform: none; white-space: normal; widows:
                  auto; word-spacing: 0px; -webkit-text-stroke-width:
                  0px; float: none; display: inline !important;"
                  class="">This is right.</span></div>
            </blockquote>
          </div>
        </blockquote>
      </blockquote>
      <blockquote
        cite="mid:2f40c5d7-d682-b174-e50a-de4e99152a4a@anl.gov"
        type="cite">
        <blockquote
          cite="mid:755F29A7-F561-4FCD-A424-829A7B03141A@gmail.com"
          type="cite">
          <div>
            <blockquote type="cite" class=""> </blockquote>
          </div>
          <br class="">
          <div class="">This sounds backwards. Returning SDValue() means
            the node should be treated as legal. Returning the original
            operation should hit the expand path.</div>
        </blockquote>
        <br>
        No, I think that was correct. The code in
        lib/CodeGen/SelectionDAG/LegalizeDAG.cpp reads:<br>
        <br>
            switch (Action) {<br>
            case TargetLowering::Legal:<br>
              return;<br>
            case TargetLowering::Custom: {<br>
              // FIXME: The handling for custom lowering with multiple
        results is<br>
              // a complete mess.<br>
              if (SDValue Res = TLI.LowerOperation(SDValue(Node, 0),
        DAG)) {<br>
                if (!(Res.getNode() != Node || Res.getResNo() != 0))<br>
                  return;<br>
        <br>
                ...<br>
        <br>
                ReplaceNode(Node, ResultVals.data());<br>
                return;<br>
              }<br>
              LLVM_FALLTHROUGH;<br>
            }<br>
            case TargetLowering::Expand:<br>
              if (ExpandNode(Node))<br>
                return;<br>
        <br>
        So, if you return an SDValue() then it will Expand. If you
        return the original node, that is equivalent to Legal.
        Otherwise, you're requesting a replacement. The logic for
        loads/stores and vectors is handled separately (but is similar).<br>
        <br>
         -Hal<br>
        <br>
        <blockquote
          cite="mid:755F29A7-F561-4FCD-A424-829A7B03141A@gmail.com"
          type="cite">
          <div class=""><br class="">
          </div>
          <div class="">-Matt</div>
          <br>
          <fieldset class="mimeAttachmentHeader"></fieldset>
          <br>
          <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
        </blockquote>
        <br>
        <pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
      </blockquote>
      <br>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
  </body>
</html>