diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2012-12-06 19:13:27 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2012-12-06 19:13:27 +0000 |
| commit | 9ec512d768cda982ef69c43a356864edbe60b8ee (patch) | |
| tree | 1329dfb5d4e0e492cdbb1804c52c9434580471df /llvm/lib/Target/ARM | |
| parent | bba0a95373f98975def49ab93d0ad6071b8bf767 (diff) | |
| download | bcm5719-llvm-9ec512d768cda982ef69c43a356864edbe60b8ee.tar.gz bcm5719-llvm-9ec512d768cda982ef69c43a356864edbe60b8ee.zip | |
Replace r169459 with something safer. Rather than having computeMaskedBits to
understand target implementation of any_extend / extload, just generate
zero_extend in place of any_extend for liveouts when the target knows the
zero_extend will be implicit (e.g. ARM ldrb / ldrh) or folded (e.g. x86 movz).
rdar://12771555
llvm-svn: 169536
Diffstat (limited to 'llvm/lib/Target/ARM')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 51 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.h | 7 |
2 files changed, 23 insertions, 35 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index c0a785338d6..32235b9d0c6 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -9462,6 +9462,27 @@ EVT ARMTargetLowering::getOptimalMemOpType(uint64_t Size, return MVT::Other; } +bool ARMTargetLowering::isZExtFree(SDValue Val, EVT VT2) const { + if (Val.getOpcode() != ISD::LOAD) + return false; + + EVT VT1 = Val.getValueType(); + if (!VT1.isSimple() || !VT1.isInteger() || + !VT2.isSimple() || !VT2.isInteger()) + return false; + + switch (VT1.getSimpleVT().SimpleTy) { + default: break; + case MVT::i1: + case MVT::i8: + case MVT::i16: + // 8-bit and 16-bit loads implicitly zero-extend to 32-bits. + return true; + } + + return false; +} + static bool isLegalT1AddressImmediate(int64_t V, EVT VT) { if (V < 0) return false; @@ -9878,36 +9899,6 @@ void ARMTargetLowering::computeMaskedBitsForTargetNode(const SDValue Op, } } -void ARMTargetLowering::computeMaskedBitsForAnyExtend(const SDValue Op, - APInt &KnownZero, - APInt &KnownOne, - const SelectionDAG &DAG, - unsigned Depth) const { - unsigned BitWidth = Op.getValueType().getScalarType().getSizeInBits(); - if (Op.getOpcode() == ISD::ANY_EXTEND) { - // Implemented as a zero_extend. - EVT InVT = Op.getOperand(0).getValueType(); - unsigned InBits = InVT.getScalarType().getSizeInBits(); - KnownZero = KnownZero.trunc(InBits); - KnownOne = KnownOne.trunc(InBits); - DAG.ComputeMaskedBits(Op.getOperand(0), KnownZero, KnownOne, Depth+1); - KnownZero = KnownZero.zext(BitWidth); - KnownOne = KnownOne.zext(BitWidth); - APInt NewBits = APInt::getHighBitsSet(BitWidth, BitWidth - InBits); - KnownZero |= NewBits; - return; - } else if (ISD::isEXTLoad(Op.getNode())) { - // Implemented as zextloads. - LoadSDNode *LD = cast<LoadSDNode>(Op); - EVT VT = LD->getMemoryVT(); - unsigned MemBits = VT.getScalarType().getSizeInBits(); - KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - MemBits); - return; - } - - assert(0 && "Expecting an ANY_EXTEND or extload!"); -} - //===----------------------------------------------------------------------===// // ARM Inline Assembly Support //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/ARM/ARMISelLowering.h b/llvm/lib/Target/ARM/ARMISelLowering.h index bde2ad49245..8f7b593cbf5 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.h +++ b/llvm/lib/Target/ARM/ARMISelLowering.h @@ -294,6 +294,8 @@ namespace llvm { bool MemcpyStrSrc, MachineFunction &MF) const; + virtual bool isZExtFree(SDValue Val, EVT VT2) const; + /// isLegalAddressingMode - Return true if the addressing mode represented /// by AM is legal for this target, for a load/store of the specified type. virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty)const; @@ -333,11 +335,6 @@ namespace llvm { const SelectionDAG &DAG, unsigned Depth) const; - virtual void computeMaskedBitsForAnyExtend(const SDValue Op, - APInt &KnownZero, - APInt &KnownOne, - const SelectionDAG &DAG, - unsigned Depth) const; virtual bool ExpandInlineAsm(CallInst *CI) const; |

