-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Remove unnecessary add instructions in ctlz.i8 #77615
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 |
---|---|---|
|
@@ -446,6 +446,9 @@ AMDGPUTargetLowering::AMDGPUTargetLowering(const TargetMachine &TM, | |
{ISD::CTTZ, ISD::CTTZ_ZERO_UNDEF, ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF}, | ||
MVT::i64, Custom); | ||
|
||
for (auto VT : {MVT::i8, MVT::i16}) | ||
setOperationAction({ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF}, VT, Custom); | ||
|
||
static const MVT::SimpleValueType VectorIntTypes[] = { | ||
MVT::v2i32, MVT::v3i32, MVT::v4i32, MVT::v5i32, MVT::v6i32, MVT::v7i32, | ||
MVT::v9i32, MVT::v10i32, MVT::v11i32, MVT::v12i32}; | ||
|
@@ -1398,6 +1401,11 @@ void AMDGPUTargetLowering::ReplaceNodeResults(SDNode *N, | |
if (SDValue Lowered = lowerFEXP(SDValue(N, 0), DAG)) | ||
Results.push_back(Lowered); | ||
return; | ||
case ISD::CTLZ: | ||
case ISD::CTLZ_ZERO_UNDEF: | ||
if (auto Lowered = lowerCTLZResults(SDValue(N, 0u), DAG)) | ||
Results.push_back(Lowered); | ||
return; | ||
default: | ||
return; | ||
} | ||
|
@@ -3063,6 +3071,26 @@ static bool isCttzOpc(unsigned Opc) { | |
return Opc == ISD::CTTZ || Opc == ISD::CTTZ_ZERO_UNDEF; | ||
} | ||
|
||
SDValue AMDGPUTargetLowering::lowerCTLZResults(SDValue Op, | ||
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: I know you've already changed the name once, but isn't this really doing integer result promotion (as in 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. I'm happy to change the name if there are no objections? I think "lowerX" was preferred for consistency with the other functions in |
||
SelectionDAG &DAG) const { | ||
auto SL = SDLoc(Op); | ||
auto Arg = Op.getOperand(0u); | ||
auto ResultVT = Op.getValueType(); | ||
|
||
if (ResultVT != MVT::i8 && ResultVT != MVT::i16) | ||
return {}; | ||
|
||
assert(isCtlzOpc(Op.getOpcode())); | ||
assert(ResultVT == Arg.getValueType()); | ||
|
||
auto const LeadingZeroes = 32u - ResultVT.getFixedSizeInBits(); | ||
auto NewOp = DAG.getNode(ISD::ZERO_EXTEND, SL, MVT::i32, Arg); | ||
auto ShiftVal = DAG.getConstant(LeadingZeroes, SL, MVT::i32); | ||
NewOp = DAG.getNode(ISD::SHL, SL, MVT::i32, NewOp, ShiftVal); | ||
NewOp = DAG.getNode(Op.getOpcode(), SL, MVT::i32, NewOp); | ||
return DAG.getNode(ISD::TRUNCATE, SL, ResultVT, NewOp); | ||
Comment on lines
+3086
to
+3091
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. Unfortunate duplication of generic legalization logic |
||
} | ||
|
||
SDValue AMDGPUTargetLowering::LowerCTLZ_CTTZ(SDValue Op, SelectionDAG &DAG) const { | ||
SDLoc SL(Op); | ||
SDValue Src = Op.getOperand(0); | ||
|
Uh oh!
There was an error while loading. Please reload this page.