diff options
| author | Richard Osborne <richard@xmos.com> | 2010-03-09 16:34:25 +0000 |
|---|---|---|
| committer | Richard Osborne <richard@xmos.com> | 2010-03-09 16:34:25 +0000 |
| commit | e8841ba46b9ebfc0e58fb84fe9193f5546c4ac8f (patch) | |
| tree | 53a6f44af18843b18baac00b3e46cbd5ba896738 /lib/Target/XCore/XCoreISelLowering.cpp | |
| parent | 36439e28fc68c7205daade81259f810cc4ae0750 (diff) | |
| download | external_llvm-e8841ba46b9ebfc0e58fb84fe9193f5546c4ac8f.zip external_llvm-e8841ba46b9ebfc0e58fb84fe9193f5546c4ac8f.tar.gz external_llvm-e8841ba46b9ebfc0e58fb84fe9193f5546c4ac8f.tar.bz2 | |
In cases where the carry / borrow unused converted ladd / lsub
to an add or a sub.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/XCore/XCoreISelLowering.cpp')
| -rw-r--r-- | lib/Target/XCore/XCoreISelLowering.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp index d8cbd03..7ecd151 100644 --- a/lib/Target/XCore/XCoreISelLowering.cpp +++ b/lib/Target/XCore/XCoreISelLowering.cpp @@ -1117,6 +1117,21 @@ SDValue XCoreTargetLowering::PerformDAGCombine(SDNode *N, SDValue Ops [] = { Carry, Result }; return DAG.getMergeValues(Ops, 2, dl); } + + // fold (ladd x, 0, y) -> 0, add x, y iff carry is unused and y has only the + // low bit set + if (N1C && N1C->isNullValue() && N->hasNUsesOfValue(0, 0)) { + APInt KnownZero, KnownOne; + APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(), + VT.getSizeInBits() - 1); + DAG.ComputeMaskedBits(N2, Mask, KnownZero, KnownOne); + if (KnownZero == Mask) { + SDValue Carry = DAG.getConstant(0, VT); + SDValue Result = DAG.getNode(ISD::ADD, dl, VT, N0, N2); + SDValue Ops [] = { Carry, Result }; + return DAG.getMergeValues(Ops, 2, dl); + } + } } break; case XCoreISD::LSUB: { @@ -1141,6 +1156,21 @@ SDValue XCoreTargetLowering::PerformDAGCombine(SDNode *N, return DAG.getMergeValues(Ops, 2, dl); } } + + // fold (lsub x, 0, y) -> 0, sub x, y iff borrow is unused and y has only the + // low bit set + if (N1C && N1C->isNullValue() && N->hasNUsesOfValue(0, 0)) { + APInt KnownZero, KnownOne; + APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(), + VT.getSizeInBits() - 1); + DAG.ComputeMaskedBits(N2, Mask, KnownZero, KnownOne); + if (KnownZero == Mask) { + SDValue Borrow = DAG.getConstant(0, VT); + SDValue Result = DAG.getNode(ISD::SUB, dl, VT, N0, N2); + SDValue Ops [] = { Borrow, Result }; + return DAG.getMergeValues(Ops, 2, dl); + } + } } break; case ISD::STORE: { |
