[PATCH] D139422: [AMDGPU] Accelerate SIRegisterInfo::getPhysRegClass
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 02:37:33 PST 2022
foad accepted this revision.
foad added a comment.
This revision is now accepted and ready to land.
LGTM.
================
Comment at: llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp:2796
SIRegisterInfo::getPhysRegClass(MCRegister Reg) const {
- static const TargetRegisterClass *const BaseClasses[] = {
- &AMDGPU::VGPR_LO16RegClass,
- &AMDGPU::VGPR_HI16RegClass,
- &AMDGPU::SReg_LO16RegClass,
- &AMDGPU::AGPR_LO16RegClass,
- &AMDGPU::VGPR_32RegClass,
- &AMDGPU::SReg_32RegClass,
- &AMDGPU::AGPR_32RegClass,
- &AMDGPU::AGPR_32RegClass,
- &AMDGPU::VReg_64_Align2RegClass,
- &AMDGPU::VReg_64RegClass,
- &AMDGPU::SReg_64RegClass,
- &AMDGPU::AReg_64_Align2RegClass,
- &AMDGPU::AReg_64RegClass,
- &AMDGPU::VReg_96_Align2RegClass,
- &AMDGPU::VReg_96RegClass,
- &AMDGPU::SReg_96RegClass,
- &AMDGPU::AReg_96_Align2RegClass,
- &AMDGPU::AReg_96RegClass,
- &AMDGPU::VReg_128_Align2RegClass,
- &AMDGPU::VReg_128RegClass,
- &AMDGPU::SReg_128RegClass,
- &AMDGPU::AReg_128_Align2RegClass,
- &AMDGPU::AReg_128RegClass,
- &AMDGPU::VReg_160_Align2RegClass,
- &AMDGPU::VReg_160RegClass,
- &AMDGPU::SReg_160RegClass,
- &AMDGPU::AReg_160_Align2RegClass,
- &AMDGPU::AReg_160RegClass,
- &AMDGPU::VReg_192_Align2RegClass,
- &AMDGPU::VReg_192RegClass,
- &AMDGPU::SReg_192RegClass,
- &AMDGPU::AReg_192_Align2RegClass,
- &AMDGPU::AReg_192RegClass,
- &AMDGPU::VReg_224_Align2RegClass,
- &AMDGPU::VReg_224RegClass,
- &AMDGPU::SReg_224RegClass,
- &AMDGPU::AReg_224_Align2RegClass,
- &AMDGPU::AReg_224RegClass,
- &AMDGPU::VReg_256_Align2RegClass,
- &AMDGPU::VReg_256RegClass,
- &AMDGPU::SReg_256RegClass,
- &AMDGPU::AReg_256_Align2RegClass,
- &AMDGPU::AReg_256RegClass,
- &AMDGPU::VReg_288_Align2RegClass,
- &AMDGPU::VReg_288RegClass,
- &AMDGPU::SReg_288RegClass,
- &AMDGPU::AReg_288_Align2RegClass,
- &AMDGPU::AReg_288RegClass,
- &AMDGPU::VReg_320_Align2RegClass,
- &AMDGPU::VReg_320RegClass,
- &AMDGPU::SReg_320RegClass,
- &AMDGPU::AReg_320_Align2RegClass,
- &AMDGPU::AReg_320RegClass,
- &AMDGPU::VReg_352_Align2RegClass,
- &AMDGPU::VReg_352RegClass,
- &AMDGPU::SReg_352RegClass,
- &AMDGPU::AReg_352_Align2RegClass,
- &AMDGPU::AReg_352RegClass,
- &AMDGPU::VReg_384_Align2RegClass,
- &AMDGPU::VReg_384RegClass,
- &AMDGPU::SReg_384RegClass,
- &AMDGPU::AReg_384_Align2RegClass,
- &AMDGPU::AReg_384RegClass,
- &AMDGPU::VReg_512_Align2RegClass,
- &AMDGPU::VReg_512RegClass,
- &AMDGPU::SReg_512RegClass,
- &AMDGPU::AReg_512_Align2RegClass,
- &AMDGPU::AReg_512RegClass,
- &AMDGPU::SReg_1024RegClass,
- &AMDGPU::VReg_1024_Align2RegClass,
- &AMDGPU::VReg_1024RegClass,
- &AMDGPU::AReg_1024_Align2RegClass,
- &AMDGPU::AReg_1024RegClass,
- &AMDGPU::SCC_CLASSRegClass,
- &AMDGPU::Pseudo_SReg_32RegClass,
- &AMDGPU::Pseudo_SReg_128RegClass,
- };
-
- for (const TargetRegisterClass *BaseClass : BaseClasses) {
- if (BaseClass->contains(Reg)) {
- return BaseClass;
- }
- }
- return nullptr;
+ if (Reg >= PhysRegClass.size())
+ return nullptr;
----------------
Surely you can assert this?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139422/new/
https://reviews.llvm.org/D139422
More information about the llvm-commits
mailing list