summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-09-08 12:58:12 +0000
committerJames Molloy <james.molloy@arm.com>2016-09-08 12:58:12 +0000
commit753c18f5c00bf64de66b584a252933961bc99df5 (patch)
treed00b91a8e6afce9431f4f60e3daed66f2f59847f /llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
parent7c7255e40b9115802987690516fb10301e22a313 (diff)
downloadbcm5719-llvm-753c18f5c00bf64de66b584a252933961bc99df5.tar.gz
bcm5719-llvm-753c18f5c00bf64de66b584a252933961bc99df5.zip
[Thumb1] AND with a constant operand can be converted into BIC
So model the cost of materializing the constant operand C as the minimum of C and ~C. llvm-svn: 280929
Diffstat (limited to 'llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp')
-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 2d44adc9951..48819335512 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -69,6 +69,10 @@ int ARMTTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
Idx == 1)
return 0;
+ if (Opcode == Instruction::And)
+ // Conversion to BIC is free, and means we can use ~Imm instead.
+ return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty));
+
return getIntImmCost(Imm, Ty);
}
OpenPOWER on IntegriCloud