OSDN Git Service

[Thumb] Reapply r272251 with a fix for PR28348
authorJames Molloy <james.molloy@arm.com>
Mon, 4 Jul 2016 16:35:41 +0000 (16:35 +0000)
committerJames Molloy <james.molloy@arm.com>
Mon, 4 Jul 2016 16:35:41 +0000 (16:35 +0000)
commiteb181e82b8bf9eb57cdacc2ea16695c828e3c18f
treedd46f5fd221146a4b85e1a0dd3a0cda20023ac8f
parentf371eaddb2b775686047c34097b3287a72b141ef
[Thumb] Reapply r272251 with a fix for PR28348

We were using DAG->getConstant instead of DAG->getTargetConstant. This meant that we could inadvertently increase the use count of a constant if stars aligned, which it did in this testcase. Increasing the use count of the constant could cause ISel to fall over (because DAGToDAG lowering assumed the constant had only one use!)

Original commit message:
  [Thumb] Select a BIC instead of AND if the immediate can be encoded more optimally negated

  If an immediate is only used in an AND node, it is possible that the immediate can be more optimally materialized when negated. If this is the case, we can negate the immediate and use a BIC instead;

    int i(int a) {
      return a & 0xfffffeec;
    }

  Used to produce:
      ldr r1, [CONSTPOOL]
      ands r0, r1
    CONSTPOOL: 0xfffffeec

  And now produces:
      movs    r1, #255
      adds    r1, #20  ; Less costly immediate generation
      bics    r0, r1

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274510 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelDAGToDAG.cpp
test/CodeGen/Thumb/bic_imm.ll [new file with mode: 0644]
test/CodeGen/Thumb2/bicbfi.ll [new file with mode: 0644]