[llvm-bugs] [Bug 34106] New: ARMTargetLowering::isLegalAddressingMode can accept incorrect addressing modes for Thumb1 target

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 7 10:11:39 PDT 2017


            Bug ID: 34106
           Summary: ARMTargetLowering::isLegalAddressingMode can accept
                    incorrect addressing modes for Thumb1 target
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: eastig at yandex.ru
                CC: llvm-bugs at lists.llvm.org

This bug report is a result of investigation of performance regressions on
Cortex-M0+ and Cortex-M23 triggered by the changes:

See a discussion thread
for more information about the investigation.

The current code of ARMTargetLowering::isLegalAddressingMode:

bool ARMTargetLowering::isLegalAddressingMode(const DataLayout &DL,
                                              const AddrMode &AM, Type *Ty,
                                              unsigned AS, Instruction *I)
const {
  EVT VT = getValueType(DL, Ty, true);
  if (!isLegalAddressImmediate(AM.BaseOffs, VT, Subtarget))
    return false;

  // Can never fold addr of global into load/store.
  if (AM.BaseGV)
    return false;

  switch (AM.Scale) {
  case 0:  // no scale reg, must be "r+i" or "r", or "i".
  case 1:
    if (Subtarget->isThumb1Only())
      return false;
    // ARM doesn't support any R+R*scale+imm addr modes.
    if (AM.BaseOffs)
      return false;

    if (!VT.isSimple())
      return false;

    if (Subtarget->isThumb2())
      return isLegalT2ScaledAddressingMode(AM, VT);

For the Thumb1 target the code returns false when AM.Scale equals 1. It returns
true when AM.Scale equals 4, for example. AM.Scale == 1 which actually means no
scaling so the Thumb1 target can accept it. Other Scale values can be accepted
by the Thumb1 target because its addressing modes do not support scaling.

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/20170807/d5303dbb/attachment.html>

More information about the llvm-bugs mailing list