<html>
    <head>
      <base href="https://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 --- - wrong codegen (miscompile) for weird type"
   href="https://llvm.org/bugs/show_bug.cgi?id=27825">27825</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wrong codegen (miscompile) for weird type
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As noted here:
<a href="https://groups.google.com/d/msg/llvm-dev/QhPhmkfwWmY/XCyol-XjCAAJ">https://groups.google.com/d/msg/llvm-dev/QhPhmkfwWmY/XCyol-XjCAAJ</a>

Something (during DAG type legalization?) is going wrong in this simple
example: 

@g = constant i8 128
define i8 @main() {
  %ptr = bitcast i8* @g to i7*
  %v7 = load i7, i7* %ptr
;  br label %cmp
;  cmp:
  %ret = zext i7 %v7 to i8
  ret i8 %ret
}

$ ./llc -o - i7.ll | ./clang -x assembler - -o i7 && ./i7 ; echo $?
128

The high bit of the i8 value should have been masked off. If you uncomment the
branch+label, it works as expected (but we should confirm that's not two wrongs
making it right):

$ ./llc -o - i7.ll | ./clang -x assembler - -o i7 && ./i7 ; echo $?
0</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>