-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[DAG] Fold (and X, (bswap/bitreverse (not Y))) -> (and X, (not (bswap/bitreverse Y))) #112547
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 |
|---|---|---|
|
|
@@ -7353,6 +7353,17 @@ SDValue DAGCombiner::visitAND(SDNode *N) { | |
| if (SDValue R = foldLogicOfShifts(N, N1, N0, DAG)) | ||
| return R; | ||
|
|
||
| // Fold (and X, (bswap (not Y))) -> (and X, (not (bswap Y))) | ||
| // Fold (and X, (bitreverse (not Y))) -> (and X, (not (bitreverse Y))) | ||
| SDValue X, Y, NotY; | ||
| for (unsigned Opc : {ISD::BSWAP, ISD::BITREVERSE}) | ||
| if (sd_match(N, | ||
| m_And(m_Value(X), m_OneUse(m_UnaryOp(Opc, m_Value(NotY))))) && | ||
| sd_match(NotY, m_Not(m_Value(Y))) && | ||
| (TLI.hasAndNot(SDValue(N, 0)) || NotY->hasOneUse())) | ||
|
||
| return DAG.getNode(ISD::AND, DL, VT, X, | ||
| DAG.getNOT(DL, DAG.getNode(Opc, DL, VT, Y), VT)); | ||
|
|
||
| // Masking the negated extension of a boolean is just the zero-extended | ||
| // boolean: | ||
| // and (sub 0, zext(bool X)), 1 --> zext(bool X) | ||
|
|
||
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.
Maybe should be
|| (NotY->hasOneUse() && sd_match(X, m_Not(m_Value()))There is a lot of diff from just re-assosiating the not which seems netural.
No strong opinion, however.