<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 --- - !range metadata pessimizes generated assembly"
   href="https://llvm.org/bugs/show_bug.cgi?id=30505">30505</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>!range metadata pessimizes generated assembly
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Transformation Utilities
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>simonas+llvm.org@kazlauskas.me
          </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>Created <span class=""><a href="attachment.cgi?id=17340" name="attach_17340" title="Case where pessimisation happens">attachment 17340</a> <a href="attachment.cgi?id=17340&action=edit" title="Case where pessimisation happens">[details]</a></span>
Case where pessimisation happens

In the attached test case the instruction

    %1 = load i8, i8* %0, !range !1

has range metadata attached to it. In LLVM 3.9 Combine Redundant instructions
pass replaces this load with

    %1 = load i8, i8* %0, align 1, !range !1
    %trunc = trunc i8 %1 to i2

The truncation ends up never getting removed and results in extra and
unnecessary `andb $3, %dil` instruction in the optimised assembly. This extra
instruction is causing some noticeable overhead in a tight loop.

---

LLVM 3.8 does not apply the transformation detailed above. Therefore it does
not emit the superfluous `andb` instruction either.

As far as fixes are concerned, perhaps it would make sense to only `trunc` to
the bitwidths supported by the target machine?</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>