[PATCH] D138044: AMDGPU/GlobalISel: Fix crash after mad/fma_mix fails selection

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 17 08:47:35 PST 2022


Petar.Avramovic added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp:3415
+                                               bool ForceVGPR) const {
   if ((Mods != 0 || ForceVGPR) &&
       RBI.getRegBank(Src, *MRI, TRI)->getID() != AMDGPU::VGPRRegBankID) {
----------------
arsenm wrote:
> Unrelated, but I don't understand why this modifier check is here. It doesn't factor into the constant bus restriction 
I wanted to remove both checks, also build copy into a vgpr class but there were way too many changes in regression tests (mostly mir).
In those tests instructions have sgpr inputs (there is no copy).
Here is the summary of the effects of Mods != 0 and cloneVirtualRegister
sgpr input without mods, stays sgpr no copy
sgpr input with mods, creates copy but copy is still to sgpr! (cloneVirtualRegister is for Root, which was sgpr) not vgpr

 In default use case (to my understanding at least) all checks could be removed
instructions that fold these mods have inputs with vgpr reg bank
Mods != 0 is most probably fast exit since operand should have already been vgpr
cloneVirtualRegister is just a convenience and avoids having to get reg class from register (needs llt, then size in bits and call to helper that will get the class)



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138044/new/

https://reviews.llvm.org/D138044



More information about the llvm-commits mailing list