diff options
author | Andrew Trick <atrick@apple.com> | 2012-07-18 18:34:27 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-07-18 18:34:27 +0000 |
commit | a22cdb713b5dfc247807f42684449274e5d6db57 (patch) | |
tree | 7a67814c751cb72a2da2adf03c45f49dd8dd3740 /llvm/lib/Target/ARM/ARMISelLowering.cpp | |
parent | bc325168c3341dfaf35b2c027683ced82d6d9d23 (diff) | |
download | bcm5719-llvm-a22cdb713b5dfc247807f42684449274e5d6db57.tar.gz bcm5719-llvm-a22cdb713b5dfc247807f42684449274e5d6db57.zip |
Fix ARMTargetLowering::isLegalAddImmediate to consider thumb encodings.
Based on Evan's suggestion without a commitable test.
llvm-svn: 160441
Diffstat (limited to 'llvm/lib/Target/ARM/ARMISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 6094811caa5..04370c095cd 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -9046,12 +9046,19 @@ bool ARMTargetLowering::isLegalICmpImmediate(int64_t Imm) const { return Imm >= 0 && Imm <= 255; } -/// isLegalAddImmediate - Return true if the specified immediate is legal -/// add immediate, that is the target has add instructions which can add -/// a register with the immediate without having to materialize the +/// isLegalAddImmediate - Return true if the specified immediate is a legal add +/// *or sub* immediate, that is the target has add or sub instructions which can +/// add a register with the immediate without having to materialize the /// immediate into a register. bool ARMTargetLowering::isLegalAddImmediate(int64_t Imm) const { - return ARM_AM::getSOImmVal(Imm) != -1; + // Same encoding for add/sub, just flip the sign. + int64_t AbsImm = llvm::abs64(Imm); + if (!Subtarget->isThumb()) + return ARM_AM::getSOImmVal(AbsImm) != -1; + if (Subtarget->isThumb2()) + return ARM_AM::getT2SOImmVal(AbsImm) != -1; + // Thumb1 only has 8-bit unsigned immediate. + return AbsImm >= 0 && AbsImm <= 255; } static bool getARMIndexedAddressParts(SDNode *Ptr, EVT VT, |