<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - @sdiv3 and @sdiv5 tests in test/Transforms/InstCombine/exact.ll are miscompiles for undef"
   href="https://bugs.llvm.org/show_bug.cgi?id=44327">44327</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>@sdiv3 and @sdiv5 tests in test/Transforms/InstCombine/exact.ll are miscompiles for undef
          </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>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Noticed accidentally when looking at <a href="https://reviews.llvm.org/D71568">https://reviews.llvm.org/D71568</a> and trying
to ensure that the baseline udiv-by-select tests aren't miscompiles also.

----------------------------------------
define i32 @sdiv3(i32 %x) {
%0:
  %y = sdiv i32 %x, 3
  %z = mul i32 %y, 3
  ret i32 %z
}
=>
define i32 @sdiv3(i32 %x) {
%0:
  %1 = srem i32 %x, 3
  %z = sub i32 %x, %1
  ret i32 %z
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
i32 %x = undef

Source:
i32 %y = #x00000000 (0) [based on undef value]
i32 %z = #x00000000 (0)

Target:
i32 %1 = #x00000000 (0)
i32 %z = #x00010000 (65536)
Source value: #x00000000 (0)
Target value: #x00010000 (65536)

----------------------------------------
define i32 @sdiv5(i32 %x) {
%0:
  %y = sdiv i32 %x, 3
  %z = mul i32 %y, 4294967293
  ret i32 %z
}
=>
define i32 @sdiv5(i32 %x) {
%0:
  %1 = srem i32 %x, 3
  %z = sub i32 %1, %x
  ret i32 %z
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
i32 %x = undef

Source:
i32 %y = #x00000000 (0) [based on undef value]
i32 %z = #x00000000 (0)

Target:
i32 %1 = #x00000000 (0)
i32 %z = #x10000000 (268435456)
Source value: #x00000000 (0)
Target value: #x10000000 (268435456)</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>