-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[DAG] Cleanup MatchFunnelPosNeg by using SDPatternMatch matchers
#129431
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
Conversation
|
@llvm/pr-subscribers-llvm-selectiondag Author: Rajveer Singh Bharadwaj (Rajveer100) ChangesResolves #129034 Full diff: https://github.com/llvm/llvm-project/pull/129431.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 8c51cb3af6142..805c1eec6cac0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8528,6 +8528,13 @@ SDValue DAGCombiner::MatchFunnelPosNeg(SDValue N0, SDValue N1, SDValue Pos,
return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos);
}
+ SDValue X1, Y;
+ if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) &&
+ sd_match(InnerNeg, m_Xor(Y, m_SpecificInt(EltBits - 1))) &&
+ Y == InnerPos && TLI.isOperationLegalOrCustom(ISD::FSHL, VT)) {
+ return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos);
+ }
+
// fold (or (shl (shl x0, 1), (xor y, 31)), (srl x1, y))
// -> (fshr x0, x1, y)
if (IsBinOpImm(N0, ISD::SHL, 1) &&
|
|
@RKSimon |
|
|
||
| SDValue X1, Y; | ||
| if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) && | ||
| sd_match(InnerNeg, m_Xor(Y, m_SpecificInt(EltBits - 1))) && |
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.
You can remove Y and use m_Specific(InnerPos)
| InnerPos == InnerNeg.getOperand(0) && | ||
| TLI.isOperationLegalOrCustom(ISD::FSHL, VT)) { | ||
| return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos); | ||
| } |
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.
This should be removed entirely
| if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) && | ||
| sd_match(InnerNeg, m_Xor(Y, m_SpecificInt(EltBits - 1))) && | ||
| Y == InnerPos && TLI.isOperationLegalOrCustom(ISD::FSHL, VT)) { | ||
| return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos); |
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.
N1.getOperand(0) -> X1
| } | ||
|
|
||
| SDValue X1, Y; | ||
| if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) && |
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.
X1 -> m_Value(X1)
No description provided.