<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 --- - InstCombiner::commonIDivTransforms: incorrect transformation"
   href="http://llvm.org/bugs/show_bug.cgi?id=21243">21243</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>InstCombiner::commonIDivTransforms: incorrect transformation
          </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>One transformation done in InstCombiner::commonIDivTransforms()
(InstCombineMulDivRem.cpp) is incorrect:

(X / C1) / C2  -> 0
if C1*C2 overflows

In the following counterexample, we can see that even C1*C2 overflows (it does,
the result would be = 2), the final result may be non-zero.

----------------------------------------
Pre: !WillNotOverflowSignedMul(C1, C2)
%Op0 = sdiv %X, C1
%r = sdiv %Op0, C2
  =>
%r = 0

Done: 1
ERROR: Mismatch in values of i2 %r

Example:
%X i2 = 2 (0x2)
C1 i2 = 2 (0x2)
C2 i2 = 3 (0x3)
%Op0 i2 = 1 (0x1)
Source value: 3 (0x3)
Target value: 0 (0x0)</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>