<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 - [DAG] Missing constant fold in avg pattern"
   href="https://bugs.llvm.org/show_bug.cgi?id=44973">44973</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DAG] Missing constant fold in avg pattern
          </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>Windows NT
          </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>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, nikita.ppv@gmail.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>So, I was trying to improve the codegen in llvm\test\CodeGen\X86\avg.ll for the
'not_avg_v16i8_wide_constants' test case as its incredibly inefficient wrt
demandedbits and shuffle combining:

Then I discovered this: <a href="https://gcc.godbolt.org/z/WbMDbA">https://gcc.godbolt.org/z/WbMDbA</a>

define void @not_avg_v16i8_wide_constants(<16 x i8>* %a, <16 x i8>* %b, <16 x
i8>* %c) {
  %1 = load <16 x i8>, <16 x i8>* %a
  %2 = load <16 x i8>, <16 x i8>* %b
  %3 = zext <16 x i8> %1 to <16 x i128>
  %4 = zext <16 x i8> %2 to <16 x i128>
  %5 = add nuw nsw <16 x i128> %3, <i128 -1, i128 -1, i128 -1, i128 -1, i128
-1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1,
i128 -1, i128 -1, i128 -1>
  %6 = add nuw nsw <16 x i128> %5, %4
  %7 = lshr <16 x i128> %6, <i128 1, i128 1, i128 1, i128 1, i128 1, i128 1,
i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1>
  %8 = trunc <16 x i128> %7 to <16 x i8>
  store <16 x i8> %8, <16 x i8>* %c, align 4
  ret void
}

-mcpu=btver2 -instsimplify

define void @not_avg_v16i8_wide_constants(<16 x i8>* %a, <16 x i8>* %b, <16 x
i8>* %c) {
  store <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8
-1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8>* %c, align 4
  ret void
}

So, it looks like we're missing some constant folding / value tracking in
DAG....</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>