<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 - LLVM 13 regression: lost transformation x < C && y < C && z < C to (x | y | z) < C"
   href="https://bugs.llvm.org/show_bug.cgi?id=51745">51745</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM 13 regression: lost transformation x < C && y < C && z < C to  (x | y | z) < C
          </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>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>x < C && y < C && z < C to  (x | y | z) < C  where C is power of two.


bool
src1 (unsigned x, unsigned y, unsigned z, unsigned w)
{
  return x < 1024 && y < 1024 && z < 1024 && w < 1024;
}

bool
tgt1 (unsigned x, unsigned y, unsigned z, unsigned w)
{
  return (x | y | z | w) < 1024;
}



GCC:
src1(unsigned int, unsigned int, unsigned int, unsigned int):
        or      edx, ecx
        or      edx, esi
        or      edx, edi
        cmp     edx, 1023
        setbe   al
        ret
tgt1(unsigned int, unsigned int, unsigned int, unsigned int):
        or      edx, ecx
        or      edx, esi
        or      edx, edi
        cmp     edx, 1023
        setbe   al
        ret

Clang trunk:
src1(unsigned int, unsigned int, unsigned int, unsigned int):                  
         # @src1(unsigned int, unsigned int, unsigned int, unsigned int)
        cmp     edi, 1024
        setb    al
        cmp     esi, 1024
        setb    sil
        and     sil, al
        cmp     edx, 1024
        setb    dl
        cmp     ecx, 1024
        setb    al
        and     al, dl
        and     al, sil
        ret
tgt1(unsigned int, unsigned int, unsigned int, unsigned int):                  
         # @tgt1(unsigned int, unsigned int, unsigned int, unsigned int)
        or      edi, esi
        or      edx, ecx
        or      edx, edi
        cmp     edx, 1024
        setb    al
        ret


Regressed with LLVM 13 which disabled select-to-or optimization.</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>