-
Notifications
You must be signed in to change notification settings - Fork 14.3k
AMDGPU/GlobalISel: AMDGPURegBankSelect #112863
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 |
---|---|---|
|
@@ -7,12 +7,16 @@ | |
//===----------------------------------------------------------------------===// | ||
|
||
#include "AMDGPUGlobalISelUtils.h" | ||
#include "MCTargetDesc/AMDGPUMCTargetDesc.h" | ||
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h" | ||
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h" | ||
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h" | ||
#include "llvm/CodeGenTypes/LowLevelType.h" | ||
#include "llvm/IR/Constants.h" | ||
#include "llvm/IR/IntrinsicsAMDGPU.h" | ||
|
||
using namespace llvm; | ||
using namespace AMDGPU; | ||
using namespace MIPatternMatch; | ||
|
||
std::pair<Register, unsigned> | ||
|
@@ -68,3 +72,37 @@ AMDGPU::getBaseWithConstantOffset(MachineRegisterInfo &MRI, Register Reg, | |
|
||
return std::pair(Reg, 0); | ||
} | ||
|
||
IntrinsicLaneMaskAnalyzer::IntrinsicLaneMaskAnalyzer(MachineFunction &MF) | ||
: MRI(MF.getRegInfo()) { | ||
initLaneMaskIntrinsics(MF); | ||
} | ||
|
||
bool IntrinsicLaneMaskAnalyzer::isS32S64LaneMask(Register Reg) const { | ||
return S32S64LaneMask.contains(Reg); | ||
} | ||
|
||
void IntrinsicLaneMaskAnalyzer::initLaneMaskIntrinsics(MachineFunction &MF) { | ||
for (auto &MBB : MF) { | ||
for (auto &MI : MBB) { | ||
GIntrinsic *GI = dyn_cast<GIntrinsic>(&MI); | ||
if (GI && GI->is(Intrinsic::amdgcn_if_break)) { | ||
S32S64LaneMask.insert(MI.getOperand(3).getReg()); | ||
findLCSSAPhi(MI.getOperand(0).getReg()); | ||
} | ||
|
||
if (MI.getOpcode() == AMDGPU::SI_IF || | ||
MI.getOpcode() == AMDGPU::SI_ELSE) { | ||
findLCSSAPhi(MI.getOperand(0).getReg()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void IntrinsicLaneMaskAnalyzer::findLCSSAPhi(Register Reg) { | ||
S32S64LaneMask.insert(Reg); | ||
for (const MachineInstr &LCSSAPhi : MRI.use_instructions(Reg)) { | ||
if (LCSSAPhi.isPHI()) | ||
S32S64LaneMask.insert(LCSSAPhi.getOperand(0).getReg()); | ||
} | ||
} | ||
Comment on lines
+102
to
+108
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'm curious: How sure are you/we that there can never be "nested" phis here, perhaps due to breaking out of nested loops? 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. IntrinsicLaneMaskAnalyzer is very very trivial. It only handles LCSSA phis and if.break phis. Control flow intrinsic should only be used by other control flow intrinsics. But since we run LCSSA they can also be used by lcssa-phis. findLCSSAPhi is really meant to cover intrinsics used for control flow that are affected by LCSSA pass.
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 this just working around a bug in uniformity analysis? We already special case amdgcn_if and else in isAlwaysUniform. Did this just miss if.break? 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. if.break is already forced uniform. |
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.
I don't understand why you are mixing matching the intrinsic form of if.break above, but the selected pseudos for if and else
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.
Consequence of what legalizer does, si.if and si.else are inst-selected to SI_IF and SI_ELSE in AMDGPULegalizerInfo::legalizeIntrinsic, if.break is still intrinsic for reg bank selection