[llvm-bugs] [Bug 35375] New: TableGen does not handle AND masks correctly

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 21 07:22:06 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35375

            Bug ID: 35375
           Summary: TableGen does not handle AND masks correctly
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: GlobalISel
          Assignee: unassignedbugs at nondot.org
          Reporter: diana.picus at linaro.org
                CC: llvm-bugs at lists.llvm.org

Created attachment 19455
  --> https://bugs.llvm.org/attachment.cgi?id=19455&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171121/fac91169/attachment.html>


More information about the llvm-bugs mailing list