summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/XCore/XCoreISelLowering.cpp
diff options
context:
space:
mode:
authorRichard Osborne <richard@xmos.com>2010-03-09 16:34:25 +0000
committerRichard Osborne <richard@xmos.com>2010-03-09 16:34:25 +0000
commitc420c4cb4eb649226bc882749bac9e4ecc59b218 (patch)
tree28ef082b1fe04bbf0a26bee133eaf7633a32db1c /llvm/lib/Target/XCore/XCoreISelLowering.cpp
parentc5ff63d70fbb220fc2c80af39eef987c4738f797 (diff)
downloadbcm5719-llvm-c420c4cb4eb649226bc882749bac9e4ecc59b218.tar.gz
bcm5719-llvm-c420c4cb4eb649226bc882749bac9e4ecc59b218.zip
In cases where the carry / borrow unused converted ladd / lsub
to an add or a sub. llvm-svn: 98059
Diffstat (limited to 'llvm/lib/Target/XCore/XCoreISelLowering.cpp')
-rw-r--r--llvm/lib/Target/XCore/XCoreISelLowering.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
index d8cbd037cb2..7ecd15135a9 100644
--- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/llvm/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: {
OpenPOWER on IntegriCloud