-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DAG] Add SpecificFP matcher #167438
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
base: main
Are you sure you want to change the base?
[DAG] Add SpecificFP matcher #167438
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
bcd3afc to
485284a
Compare
| if (const auto *CFP = dyn_cast<ConstantFPSDNode>(V.getNode())) | ||
| if (CFP->isExactlyValue(Val)) | ||
| return true; | ||
| return false; |
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.
Is it possible to add splat handling as well?
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.
Yes. I added. Could you, please, have a look?
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 need to use m_c_BinOp if you want to test for commutation - otherwise you need to swap the operand matchers (or you can add another test and do both!)
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.
Sure.
RKSimon
left a comment
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.
Fix unit tests
1229219 to
0c9d220
Compare
🐧 Linux x64 Test Results
|
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.
| if (ConstantFPSDNode *C = isConstOrConstSplatFP(V, /*AllowUndefs=*/true)) |
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.
Done
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.
Is this useful?
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.
Sorry, did get the question. I guess you forgot to link the code snippet
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.
Sorry, I meant why would I use m_SpecificFP(SDValue) and not just m_Specific(SDValue)?
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.
Ahh. Ok, I understood. Ok, I removed m_SpecificFP(SDValue)
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.
TBH I'd prefer to use a APFloat for matching instead of converting to/from double
@mshockwave thoughts?
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.
yeah we can provide a double version of m_SpecificFP (which you did) but for the matcher class I prefer using APFloat as well. SpecificInt_match also uses APInt.
(also, why std::optional<double>?)
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.
yeah we can provide a double version of m_SpecificFP (which you did) but for the matcher class I prefer using APFloat as well.
Done
(also, why std::optional?)
removed. That was an artifact from a previous impl.
0c9d220 to
7771c1b
Compare
b1ea084 to
b185199
Compare
b185199 to
b7fc120
Compare
This patch introduces SpeficFP matcher for SelectionDAG nodes.
This includes:
Adding SpecificFP_match() in SDPatternMatch.h.
Adding test coverage in SelectionDAGPatternMatchTest.cpp.
Closes #165566