@@ -198,6 +198,11 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
198
198
199
199
setOperationAction(ISD::UADDO, RegVT, Custom);
200
200
201
+ // On P10, the default lowering generates better code using the
202
+ // setbc instruction.
203
+ if (!Subtarget.hasP10Vector() && isPPC64)
204
+ setOperationAction(ISD::SSUBO, MVT::i32, Custom);
205
+
201
206
// Match BITREVERSE to customized fast code sequence in the td file.
202
207
setOperationAction(ISD::BITREVERSE, MVT::i32, Legal);
203
208
setOperationAction(ISD::BITREVERSE, MVT::i64, Legal);
@@ -12041,6 +12046,27 @@ SDValue PPCTargetLowering::LowerUaddo(SDValue Op, SelectionDAG &DAG) const {
12041
12046
return Res;
12042
12047
}
12043
12048
12049
+ SDValue PPCTargetLowering::LowerSSUBO(SDValue Op, SelectionDAG &DAG) const {
12050
+
12051
+ SDLoc dl(Op);
12052
+ SDValue LHS = Op.getOperand(0);
12053
+ SDValue RHS = Op.getOperand(1);
12054
+
12055
+ SDValue Sub = DAG.getNode(ISD::SUB, dl, MVT::i32, LHS, RHS);
12056
+
12057
+ SDValue Xor1 = DAG.getNode(ISD::XOR, dl, MVT::i32, RHS, LHS);
12058
+ SDValue Xor2 = DAG.getNode(ISD::XOR, dl, MVT::i32, Sub, LHS);
12059
+
12060
+ SDValue And = DAG.getNode(ISD::AND, dl, MVT::i32, Xor1, Xor2);
12061
+
12062
+ SDValue Overflow = DAG.getNode(ISD::SRL, dl, MVT::i32, And,
12063
+ DAG.getConstant(31, dl, MVT::i32));
12064
+ SDValue OverflowTrunc =
12065
+ DAG.getNode(ISD::TRUNCATE, dl, Op.getNode()->getValueType(1), Overflow);
12066
+
12067
+ return DAG.getMergeValues({Sub, OverflowTrunc}, dl);
12068
+ }
12069
+
12044
12070
/// LowerOperation - Provide custom lowering hooks for some operations.
12045
12071
///
12046
12072
SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
@@ -12063,6 +12089,8 @@ SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
12063
12089
case ISD::SETCC: return LowerSETCC(Op, DAG);
12064
12090
case ISD::INIT_TRAMPOLINE: return LowerINIT_TRAMPOLINE(Op, DAG);
12065
12091
case ISD::ADJUST_TRAMPOLINE: return LowerADJUST_TRAMPOLINE(Op, DAG);
12092
+ case ISD::SSUBO:
12093
+ return LowerSSUBO(Op, DAG);
12066
12094
12067
12095
case ISD::INLINEASM:
12068
12096
case ISD::INLINEASM_BR: return LowerINLINEASM(Op, DAG);
0 commit comments