<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - DAG Combiner can generate illegal operations"
   href="http://llvm.org/bugs/show_bug.cgi?id=21207">21207</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DAG Combiner can generate illegal operations
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stephen.montgomery333@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, resistor@mac.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Since I picked up LLVM 3.5.0, DAGCombiner::SimplifyNodeWithTwoResults is
self-inconsistent in the way it treats the low and high parts of the result. If
the high part of the result is not used, then it uses an operation that
generates only the low part provided such operation is Legal or Custom.
However, if the low part of the result is not used, it generates only the high
part provided that the operation is Legal.

There doesn't seem any good reason for this inconsistency. More importantly, it
means that the combiner can generate a Custom operation for the low part. This
is OK prior to DAG legalisation but when running post-legalisation, shouldn't
all operations be Legal (and not Custom)?

I've experimented with making the behaviour consistent, i.e. only permitting
Legal operations, and this doesn't cause any regressions in the unit test
suite.

I've tried asking on llvmdev whether it is ever acceptable for the combiner to
introduce Custom, as opposed to Legal, operations when running
post-legalisation but I've not had any responses. It feels to me like it's not
acceptable because there's no opportunity for the illegal operation to be
legalised. However, I note that at least on backend, namely MIPS, relies on
matching a Custom operation during ISel as if it were Legal so I'm not sure
what the intended behaviour is.

Prior to r199678, DAGCombiner::SimplifyNodeWithTwoResults treated both halves
consistently and, in my opinion, correctly. Now, any backend that supports a
low-part operation with a custom lowering, such as my microcontroller target,
can have legal operations converted into illegal ones.

This isn't the only place in the DAG Combiner where Custom operations can be
introduced post legalisation, but it's one that gives me concern.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>