<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 - Overeager side effect propagation generates suboptimal backend code"
   href="https://bugs.llvm.org/show_bug.cgi?id=35907">35907</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Overeager side effect propagation generates suboptimal backend code
          </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>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>dave@znu.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following two functions:

int64_t    test_signed( int64_t arg) { return (arg >> 4) & -16; }
uint64_t test_unsigned(uint64_t arg) { return (arg >> 4) & -16; }

They should generate the same "AND" instruction in the backend, but due to
intermediate side effect propagation, the unsigned version generates:

  %3 = and i64 %2, 1152921504606846960

Rather than:

  %3 = and i64 %2, -16

This leads to suboptimal code on x86 and probably other architectures due to
how immediate values are encoded into instructions via sign extension.

As a naive observer, it seems to me that this side effect propagation should
abort of the "sign" of the unsigned value changes. This will lead to better
real world code gen in the backend.</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>