-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Improve MIR pattern for FMinFMaxLegacy combine. NFC. #90968
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 |
---|---|---|
|
@@ -70,7 +70,8 @@ class AMDGPUPostLegalizerCombinerImpl : public Combiner { | |
}; | ||
|
||
// TODO: Make sure fmin_legacy/fmax_legacy don't canonicalize | ||
bool matchFMinFMaxLegacy(MachineInstr &MI, FMinFMaxLegacyInfo &Info) const; | ||
bool matchFMinFMaxLegacy(MachineInstr &MI, MachineInstr &FCmp, | ||
FMinFMaxLegacyInfo &Info) const; | ||
void applySelectFCmpToFMinToFMaxLegacy(MachineInstr &MI, | ||
const FMinFMaxLegacyInfo &Info) const; | ||
|
||
|
@@ -159,17 +160,14 @@ bool AMDGPUPostLegalizerCombinerImpl::tryCombineAll(MachineInstr &MI) const { | |
} | ||
|
||
bool AMDGPUPostLegalizerCombinerImpl::matchFMinFMaxLegacy( | ||
MachineInstr &MI, FMinFMaxLegacyInfo &Info) const { | ||
// FIXME: Type predicate on pattern | ||
if (MRI.getType(MI.getOperand(0).getReg()) != LLT::scalar(32)) | ||
return false; | ||
|
||
Register Cond = MI.getOperand(1).getReg(); | ||
if (!MRI.hasOneNonDBGUse(Cond) || | ||
!mi_match(Cond, MRI, | ||
m_GFCmp(m_Pred(Info.Pred), m_Reg(Info.LHS), m_Reg(Info.RHS)))) | ||
MachineInstr &MI, MachineInstr &FCmp, FMinFMaxLegacyInfo &Info) const { | ||
if (!MRI.hasOneNonDBGUse(FCmp.getOperand(0).getReg())) | ||
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. Is there a way to do this check in the MIR pattern? 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. No. Other uses could have sneaked 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. Sneaked in after the autogenerated matcher runs but before this match function is called? That doesn't sound right. 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. You could:
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. The G_FCMP could be used by other MIs. 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 know. I would like to write something in the pattern to check for this, instead of writing C++ to check for this. 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. Open an issue? |
||
return false; | ||
|
||
Info.Pred = | ||
static_cast<CmpInst::Predicate>(FCmp.getOperand(1).getPredicate()); | ||
Info.LHS = FCmp.getOperand(2).getReg(); | ||
Info.RHS = FCmp.getOperand(3).getReg(); | ||
Register True = MI.getOperand(2).getReg(); | ||
Register False = MI.getOperand(3).getReg(); | ||
|
||
|
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.
Am I supposed to list
$fcmp
in the defs since I am passing it into my match function? Or doesn't that count as an "external" use of$fcmp
?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.
No. I prefer to only list the
$root
. defs is probably definitions and not def in SSA.