<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: ((1 << A) >>u B) --> (1 << (A-B)) incorrect if A-B > bitwidth"
   href="http://llvm.org/bugs/show_bug.cgi?id=21274">21274</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>InstCombine: ((1 << A) >>u B) --> (1 << (A-B)) incorrect if A-B > bitwidth
          </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>nunoplopes@sapo.pt
          </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>simplifyValueKnownNonZero() in InstCombineMulDivRem.cpp simplifies the RHS of
div/rem instructions.

However, the first transformation it does on RHS doesn't seem correct:
((1 << A) >>u B) --> (1 << (A-B))


Pre: isPowerOf2(%Power)
%shl = shl %Power, %A
%Y = lshr %shl, %B
%r = udiv %X, %Y
  =>
%sub = sub %A, %B
%Y = shl %Power, %sub
%r = udiv %X, %Y


Alive says the following:
ERROR: Domain of definedness of Target is smaller than Source's for i4 %Y

Example:
%Power i4 = 0x4 (4)
%A i4 = 0x0 (0)
%B i4 = 0x1 (1)
%X i4 = 0x0 (0)
%shl i4 = 0x4 (4)
%sub i4 = 0xF (15, -1)
Source value: 0x2 (2)
Target value: undef


Can't see a fix other than removing this transformation altogether.</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>