<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 - aarch64 "bfm" matching fails with known-zero bits"
   href="https://bugs.llvm.org/show_bug.cgi?id=46152">46152</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>aarch64 "bfm" matching fails with known-zero bits
          </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>Backend: AArch64
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>efriedma@quicinc.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>arnaud.degrandmaison@arm.com, llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase (<a href="https://godbolt.org/z/WSTfEg">https://godbolt.org/z/WSTfEg</a>):

long test(long n, long m) {
  return (n & ~15) | ((m&15));
}
long test2(long n, long m) {
  return (n & ~15) | (((m<<2)&15));
}
long test3(long n, long m) {
  return (n << 4) | ((m&15));
}
long test4(long n, long m) {
  return (n << 4) | (((m<<2)&15));
}

test(long, long): // @test(long, long)
  bfxil x0, x1, #0, #4
  ret
test2(long, long): // @test2(long, long)
  lsl w9, w1, #2
  and x8, x0, #0xfffffffffffffff0
  and x9, x9, #0xc
  orr x0, x9, x8
  ret
test3(long, long): // @test3(long, long)
  bfi x1, x0, #4, #60
  mov x0, x1
  ret
test4(long, long): // @test4(long, long)
  lsl w8, w1, #2
  and x8, x8, #0xc
  bfi x8, x0, #4, #60
  mov x0, x8
  ret


Somehow, the matching is getting confused; in test4, we generate an extra
"and"; in test2 we completely fail to generate the bfxil.

Tripped over this looking into a different issue; not sure how important this
is in practice.</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>