<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 - TableGen does not handle AND masks correctly"
   href="https://bugs.llvm.org/show_bug.cgi?id=35375">35375</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>TableGen does not handle AND masks correctly
          </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>GlobalISel
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>diana.picus@linaro.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19455" name="attach_19455" title="Reproducer">attachment 19455</a> <a href="attachment.cgi?id=19455&action=edit" title="Reproducer">[details]</a></span>
Reproducer

llc -O0 -mtriple armv7-- -stop-before=expand-isel-pseudos -o - pkhbt.ll
produces a PKHBT instruction, but with -global-isel it does not. 

The GlobalISelEmitter for TableGen generates code to select the PKHBT pattern:
def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
                              (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
               IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
               [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
                                      (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
                                           0xFFFF0000)))]>,
               Requires<[IsARM, HasV6]>,
           Sched<[WriteALUsi, ReadALU]>;

The problem is that it fails when trying to compare -65536 (or 4294901760) to
0xFFFF,0000. This is because the constant in the instruction is sign extended
to 64 bits (0xFFFF,FFFF,FFFF,0000) and then compared to the non-extended 64 bit
version expected by TableGen.

In contrast, the DAGISelEmitter generates special code for AND immediates
(OPC_CheckAndImm), which does not sign extend.</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>