<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 --- - instcombine creates i96 icmp"
   href="http://llvm.org/bugs/show_bug.cgi?id=19800">19800</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>instcombine creates i96 icmp
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dan433584@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For this C++ code:

struct T
{
    unsigned a :4;
    unsigned b :1;
    unsigned c :1;
    unsigned d :10;
    unsigned e :16;
    unsigned f :15;
    unsigned g :1;
    unsigned h :15;
    unsigned i :1;
    unsigned j :15;
    unsigned k :1;
    unsigned l :15;
    unsigned m :1;
};

bool foo(T *p)
{
    return p->a >= 3;
}

clang -O2 -emit-llvm emits LLVM IR that does this:

  %bf.load = load i96* %0, align 4
  %bf.cast = and i96 %bf.load, 15
  %cmp = icmp ugt i96 %bf.cast, 2

even on targets (such as x86-64) which have explicit native integer types in
their datalayout (such as -n8:16:32:64). The i96 icmp is semantically correct,
but surprising, given the general convention that instcombine isn't supposed to
propagate non-legal types through expression trees.

In practice, SelectionDAG codegen optimizes this away by noticing that the
input to the icmp is an and with lots of leading zero bits. However, it seems
awkward to create such illegal comparisons and require SelectionDAG to optimize
them away. It's also problematic for Emscripten, which does not currently use
SelectionDAG, so doesn't currently have code to optimize away the i96
comparison.

Is it intended that instcombine promote comparisons up to illegal types like
this?</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>