Skip to content

Commit

Permalink
[AMDGPU] Remove integer division in VOPD checks
Browse files Browse the repository at this point in the history
There is no way any compiler can simplify this division, while
the check is done rather often.

Differential Revision: https://reviews.llvm.org/D152613
  • Loading branch information
rampitec committed Jun 12, 2023
1 parent f09cca4 commit e2903ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,10 @@ std::optional<unsigned> InstInfo::getInvalidCompOperandIndex(

unsigned CompOprIdx;
for (CompOprIdx = 0; CompOprIdx < Component::MAX_OPR_NUM; ++CompOprIdx) {
unsigned BanksNum = BANKS_NUM[CompOprIdx];
unsigned BanksMasks = VOPD_VGPR_BANK_MASKS[CompOprIdx];
if (OpXRegs[CompOprIdx] && OpYRegs[CompOprIdx] &&
(OpXRegs[CompOprIdx] % BanksNum == OpYRegs[CompOprIdx] % BanksNum))
((OpXRegs[CompOprIdx] & BanksMasks) ==
(OpYRegs[CompOprIdx] & BanksMasks)))
return CompOprIdx;
}

Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,9 @@ enum Component : unsigned {
MAX_OPR_NUM = DST_NUM + MAX_SRC_NUM
};

// Number of VGPR banks per VOPD component operand.
constexpr unsigned BANKS_NUM[] = {2, 4, 4, 2};
// LSB mask for VGPR banks per VOPD component operand.
// 4 banks result in a mask 3, setting 2 lower bits.
constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};

enum ComponentIndex : unsigned { X = 0, Y = 1 };
constexpr unsigned COMPONENTS[] = {ComponentIndex::X, ComponentIndex::Y};
Expand Down

0 comments on commit e2903ab

Please sign in to comment.