diff options
Diffstat (limited to 'llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp index 48819335512..13d57c0934a 100644 --- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp +++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp @@ -73,6 +73,17 @@ int ARMTTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, // Conversion to BIC is free, and means we can use ~Imm instead. return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty)); + if (Opcode == Instruction::ICmp && Imm.isNegative() && + Ty->getIntegerBitWidth() == 32) { + int64_t NegImm = -Imm.getSExtValue(); + if (ST->isThumb2() && NegImm < 1<<12) + // icmp X, #-C -> cmn X, #C + return 0; + if (ST->isThumb() && NegImm < 1<<8) + // icmp X, #-C -> adds X, #C + return 0; + } + return getIntImmCost(Imm, Ty); } |

