-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DAG] Matched Fixedwidth Pattern for ISD::AVGCEILU #85031
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
070c44d
37cda7f
e59331c
a4de503
dcd3385
46e18ef
47a7815
22d786b
4036561
abc15f8
8a8234d
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 |
---|---|---|
|
@@ -2529,6 +2529,23 @@ static SDValue foldAddSubBoolOfMaskedVal(SDNode *N, SelectionDAG &DAG) { | |
return DAG.getNode(IsAdd ? ISD::SUB : ISD::ADD, DL, VT, C1, LowBit); | ||
} | ||
|
||
// Attempt to form avgceilu(A, B) from (A | B) - ((A ^ B) >> 1) | ||
static SDValue combineFixedwidthToAVGCEILU(SDNode *N, SelectionDAG &DAG) { | ||
const TargetLowering &TLI = DAG.getTargetLoweringInfo(); | ||
SDValue N0 = N->getOperand(0); | ||
EVT VT = N0.getValueType(); | ||
SDLoc DL(N); | ||
if (TLI.isOperationLegal(ISD::AVGCEILU, VT)) { | ||
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. AVGFLOORU -> AVGCEILU This shares quite a lot with #84903 and could be combined into the same function once that is submitted. 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.
Updated.
Sure. |
||
SDValue A, B; | ||
if (sd_match(N, m_Sub(m_Or(m_Value(A), m_Value(B)), | ||
m_Srl(m_Xor(m_Deferred(A), m_Deferred(B)), | ||
m_SpecificInt(1))))) { | ||
return DAG.getNode(ISD::AVGCEILU, DL, VT, A, B); | ||
} | ||
} | ||
return SDValue(); | ||
} | ||
|
||
/// Try to fold a 'not' shifted sign-bit with add/sub with constant operand into | ||
/// a shift and add with a different constant. | ||
static SDValue foldAddSubOfSignBit(SDNode *N, SelectionDAG &DAG) { | ||
|
@@ -3849,6 +3866,10 @@ SDValue DAGCombiner::visitSUB(SDNode *N) { | |
if (SDValue V = foldAddSubOfSignBit(N, DAG)) | ||
return V; | ||
|
||
// Try to match AVGCEILU fixedwidth pattern | ||
if (SDValue V = combineFixedwidthToAVGCEILU(N, DAG)) | ||
return V; | ||
|
||
if (SDValue V = foldAddSubMasked1(false, N0, N1, DAG, SDLoc(N))) | ||
return V; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.