diff options
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp b/llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp index 5611c9c5d57e..7ba20eb6027b 100644 --- a/llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp +++ b/llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp @@ -63,30 +63,10 @@ enum HardClauseType { HARDCLAUSE_ILLEGAL, }; -HardClauseType getHardClauseType(const MachineInstr &MI) { - // On current architectures we only get a benefit from clausing loads. - if (MI.mayLoad()) { - if (SIInstrInfo::isVMEM(MI) || SIInstrInfo::isSegmentSpecificFLAT(MI)) - return HARDCLAUSE_VMEM; - if (SIInstrInfo::isFLAT(MI)) - return HARDCLAUSE_FLAT; - // TODO: LDS - if (SIInstrInfo::isSMRD(MI)) - return HARDCLAUSE_SMEM; - } - - // Don't form VALU clauses. It's not clear what benefit they give, if any. - - // In practice s_nop is the only internal instruction we're likely to see. - // It's safe to treat the rest as illegal. - if (MI.getOpcode() == AMDGPU::S_NOP) - return HARDCLAUSE_INTERNAL; - return HARDCLAUSE_ILLEGAL; -} - class SIInsertHardClauses : public MachineFunctionPass { public: static char ID; + const GCNSubtarget *ST = nullptr; SIInsertHardClauses() : MachineFunctionPass(ID) {} @@ -95,6 +75,34 @@ public: MachineFunctionPass::getAnalysisUsage(AU); } + HardClauseType getHardClauseType(const MachineInstr &MI) { + + // On current architectures we only get a benefit from clausing loads. + if (MI.mayLoad()) { + if (SIInstrInfo::isVMEM(MI) || SIInstrInfo::isSegmentSpecificFLAT(MI)) { + if (ST->hasNSAClauseBug()) { + const AMDGPU::MIMGInfo *Info = AMDGPU::getMIMGInfo(MI.getOpcode()); + if (Info && Info->MIMGEncoding == AMDGPU::MIMGEncGfx10NSA) + return HARDCLAUSE_ILLEGAL; + } + return HARDCLAUSE_VMEM; + } + if (SIInstrInfo::isFLAT(MI)) + return HARDCLAUSE_FLAT; + // TODO: LDS + if (SIInstrInfo::isSMRD(MI)) + return HARDCLAUSE_SMEM; + } + + // Don't form VALU clauses. It's not clear what benefit they give, if any. + + // In practice s_nop is the only internal instruction we're likely to see. + // It's safe to treat the rest as illegal. + if (MI.getOpcode() == AMDGPU::S_NOP) + return HARDCLAUSE_INTERNAL; + return HARDCLAUSE_ILLEGAL; + } + // Track information about a clause as we discover it. struct ClauseInfo { // The type of all (non-internal) instructions in the clause. @@ -132,12 +140,12 @@ public: if (skipFunction(MF.getFunction())) return false; - const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>(); - if (!ST.hasHardClauses()) + ST = &MF.getSubtarget<GCNSubtarget>(); + if (!ST->hasHardClauses()) return false; - const SIInstrInfo *SII = ST.getInstrInfo(); - const TargetRegisterInfo *TRI = ST.getRegisterInfo(); + const SIInstrInfo *SII = ST->getInstrInfo(); + const TargetRegisterInfo *TRI = ST->getRegisterInfo(); bool Changed = false; for (auto &MBB : MF) { |
