<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 09/29/2015 12:25 PM, Ryan Taylor via
      llvm-dev wrote:<br>
    </div>
    <blockquote
cite="mid:CABgVvXuPoMT4ES8tfcG0o=5Z7f4Xhx9cUeWywimvBZNrCxL5yA@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div>It appears that it's impossible to duplicate a node in the
          dag. For example, there is some code:</div>
      </div>
    </blockquote>
    Correct, nodes are uniqued and CSEd<br>
    <br>
    <blockquote
cite="mid:CABgVvXuPoMT4ES8tfcG0o=5Z7f4Xhx9cUeWywimvBZNrCxL5yA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>b = a * a; // a is a  global int</div>
        <div><br>
        </div>
        <div>A LD node is generated for A and it goes into both Operand
          0 and 1 of the MUL node. The issue is I'm trying to match a
          pattern of:</div>
        <div><br>
        </div>
        <div>set dstReg:$dstD  (OpNode (srcAType (load addr32:$srcA)),
          (srcBType (load addr32:$srcB)))</div>
        <div><br>
        </div>
        <div>so basically a mem, mem, reg operation.</div>
        <div><br>
        </div>
        <div>The issue is this pattern won't match in the above example
          because there is only one LD generated for 'a'. I tried to
          duplicate the LD in the dag but it doesn't show up, it always
          reduces it to only one LD no matter what, even if I have
          multiple loads in the IR also.</div>
        <div><br>
        </div>
        <div>#1. Is it possible to duplicate an exact copy of a node in
          the dag?</div>
      </div>
    </blockquote>
    No<br>
    <br>
    <blockquote
cite="mid:CABgVvXuPoMT4ES8tfcG0o=5Z7f4Xhx9cUeWywimvBZNrCxL5yA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>#2. How would I go about matching this pattern in table
          gen?</div>
      </div>
    </blockquote>
    I would be surprised that patterns that happen to match the same
    node multiple times as operands wouldn't work as is. Maybe there is
    some complexity because these nodes have chains added? Have you
    looked at the generated matching code for why it isn't selecting? If
    all else fails you should be able to use a ComplexPattern<br>
  </body>
</html>