diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-02-02 01:53:26 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-02-02 01:53:26 +0000 |
commit | 9a2ef9509e76869c3d658fb3e321d9b9e9d479d9 (patch) | |
tree | 281f55840ccfe4589688dc3533ea62b6d3b7f63b /lib/Target/ARM/ARMISelLowering.cpp | |
parent | b0636156effd9a3563d905cbbfee59826c63e2a2 (diff) | |
download | llvm-9a2ef9509e76869c3d658fb3e321d9b9e9d479d9.tar.gz llvm-9a2ef9509e76869c3d658fb3e321d9b9e9d479d9.tar.bz2 llvm-9a2ef9509e76869c3d658fb3e321d9b9e9d479d9.tar.xz |
Fix a bug in getARMCMP (which translate CondCode to ARM specific CC) when the RHS is a constant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33775 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMISelLowering.cpp')
-rw-r--r-- | lib/Target/ARM/ARMISelLowering.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index d56c3e967b..60348c1a5b 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -859,7 +859,7 @@ static bool isFloatingPointZero(SDOperand Op) { return false; } -static bool isLegalCmpImmediate(int C, bool isThumb) { +static bool isLegalCmpImmediate(unsigned C, bool isThumb) { return ( isThumb && (C & ~255U) == 0) || (!isThumb && ARM_AM::getSOImmVal(C) != -1); } @@ -869,38 +869,36 @@ static bool isLegalCmpImmediate(int C, bool isThumb) { static SDOperand getARMCmp(SDOperand LHS, SDOperand RHS, ISD::CondCode CC, SDOperand &ARMCC, SelectionDAG &DAG, bool isThumb) { if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(RHS.Val)) { - int C = (int)RHSC->getValue(); + unsigned C = RHSC->getValue(); if (!isLegalCmpImmediate(C, isThumb)) { // Constant does not fit, try adjusting it by one? switch (CC) { default: break; case ISD::SETLT: - case ISD::SETULT: case ISD::SETGE: - case ISD::SETUGE: if (isLegalCmpImmediate(C-1, isThumb)) { - switch (CC) { - default: break; - case ISD::SETLT: CC = ISD::SETLE; break; - case ISD::SETULT: CC = ISD::SETULE; break; - case ISD::SETGE: CC = ISD::SETGT; break; - case ISD::SETUGE: CC = ISD::SETUGT; break; - } + CC = (CC == ISD::SETLT) ? ISD::SETLE : ISD::SETGT; + RHS = DAG.getConstant(C-1, MVT::i32); + } + break; + case ISD::SETULT: + case ISD::SETUGE: + if (C > 0 && isLegalCmpImmediate(C-1, isThumb)) { + CC = (CC == ISD::SETULT) ? ISD::SETULE : ISD::SETUGT; RHS = DAG.getConstant(C-1, MVT::i32); } break; case ISD::SETLE: - case ISD::SETULE: case ISD::SETGT: - case ISD::SETUGT: if (isLegalCmpImmediate(C+1, isThumb)) { - switch (CC) { - default: break; - case ISD::SETLE: CC = ISD::SETLT; break; - case ISD::SETULE: CC = ISD::SETULT; break; - case ISD::SETGT: CC = ISD::SETGE; break; - case ISD::SETUGT: CC = ISD::SETUGE; break; - } + CC = (CC == ISD::SETLE) ? ISD::SETLT : ISD::SETGE; + RHS = DAG.getConstant(C+1, MVT::i32); + } + break; + case ISD::SETULE: + case ISD::SETUGT: + if (C < 0xffffffff && isLegalCmpImmediate(C+1, isThumb)) { + CC = (CC == ISD::SETULE) ? ISD::SETULT : ISD::SETUGE; RHS = DAG.getConstant(C+1, MVT::i32); } break; |