summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-09-09 13:35:36 +0000
committerJames Molloy <james.molloy@arm.com>2016-09-09 13:35:36 +0000
commit57d9dfa9ac7618aea8de6d1d1d940db6c7474737 (patch)
tree3ffd9c0c5df379168889f6cac3240cc838bc82fe /llvm/lib
parent1454e90f86101a08445287635bf5c9b74497e1f7 (diff)
downloadbcm5719-llvm-57d9dfa9ac7618aea8de6d1d1d940db6c7474737.tar.gz
bcm5719-llvm-57d9dfa9ac7618aea8de6d1d1d940db6c7474737.zip
[ARM] ADD with a negative offset can become SUB for free
So model that directly in TTI::getIntImmCost(). llvm-svn: 281044
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 13d57c0934a..10e6297ef1e 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -73,6 +73,10 @@ 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::Add)
+ // Conversion to SUB 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();
OpenPOWER on IntegriCloud