-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[PowerPC] Add custom lowering for ssubo #111748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,11 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM, | |
|
||
setOperationAction(ISD::UADDO, isPPC64 ? MVT::i64 : MVT::i32, Custom); | ||
|
||
// On P10, the default lowering generates better code using the | ||
// setbc instruction. | ||
if (!Subtarget.hasP10Vector() && isPPC64) | ||
setOperationAction(ISD::SSUBO, MVT::i32, Custom); | ||
|
||
// Match BITREVERSE to customized fast code sequence in the td file. | ||
setOperationAction(ISD::BITREVERSE, MVT::i32, Legal); | ||
setOperationAction(ISD::BITREVERSE, MVT::i64, Legal); | ||
|
@@ -12016,6 +12021,36 @@ SDValue PPCTargetLowering::LowerUaddo(SDValue Op, SelectionDAG &DAG) const { | |
return Res; | ||
} | ||
|
||
SDValue PPCTargetLowering::LowerSSUBO(SDValue Op, SelectionDAG &DAG) const { | ||
|
||
SDLoc dl(Op); | ||
|
||
SDValue LHS64 = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i64, Op.getOperand(0)); | ||
SDValue RHS64 = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i64, Op.getOperand(1)); | ||
|
||
SDValue Sub = DAG.getNode(ISD::SUB, dl, MVT::i64, LHS64, RHS64); | ||
|
||
SDValue Extsw = DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, MVT::i64, Sub, | ||
DAG.getValueType(MVT::i32)); | ||
|
||
SDValue Xor = DAG.getNode(ISD::XOR, dl, MVT::i64, Extsw, Sub); | ||
|
||
SDValue Addic = DAG.getNode(ISD::ADDC, dl, DAG.getVTList(MVT::i64, MVT::Glue), | ||
Xor, DAG.getConstant(-1, dl, MVT::i64)); | ||
|
||
SDValue Overflow = | ||
DAG.getNode(ISD::SUBE, dl, DAG.getVTList(MVT::i64, MVT::Glue), Xor, Addic, | ||
Addic.getValue(1)); | ||
|
||
SDValue OverflowTrunc = | ||
DAG.getNode(ISD::TRUNCATE, dl, Op.getNode()->getValueType(1), Overflow); | ||
SDValue SubTrunc = | ||
(Sub->getValueType(0) != Op.getNode()->getValueType(0)) | ||
? DAG.getNode(ISD::TRUNCATE, dl, Op.getNode()->getValueType(0), Sub) | ||
: Sub; | ||
return DAG.getMergeValues({SubTrunc, OverflowTrunc}, dl); | ||
} | ||
|
||
/// LowerOperation - Provide custom lowering hooks for some operations. | ||
/// | ||
SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { | ||
|
@@ -12038,6 +12073,8 @@ SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { | |
case ISD::SETCC: return LowerSETCC(Op, DAG); | ||
case ISD::INIT_TRAMPOLINE: return LowerINIT_TRAMPOLINE(Op, DAG); | ||
case ISD::ADJUST_TRAMPOLINE: return LowerADJUST_TRAMPOLINE(Op, DAG); | ||
case ISD::SSUBO: | ||
return LowerSSUBO(Op, DAG); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should we just follow the same fmt as the other lines? I realize it's not clang-format approved... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is how clang format modified it. (tried it again) |
||
|
||
case ISD::INLINEASM: | ||
case ISD::INLINEASM_BR: return LowerINLINEASM(Op, DAG); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can probably pull out
Op.getNode()->getValueType(0)
.