GlobalISel: Relax handling of G_ASSERT_* with source register classes
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 15 Apr 2022 14:54:33 +0000 (10:54 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 22 Apr 2022 14:49:50 +0000 (10:49 -0400)
commit40bc9112c079cfdbaa051e55833ec24f64d981a4
tree95d1e7ff7ec59b82d6f288dcc06cf9130dbdaf4a
parent369ef9bf6056154cf8cededce103f1f035527807
GlobalISel: Relax handling of G_ASSERT_* with source register classes

The most common situation where G_ASSERT_ZEXT appears for AMDGPU is a
copy from a physical register, which happens to use set the actual
register class on the virtual register. After copy coalescing, the
assert's source operand had a vreg with a set class. The verifier was
strictly rejecting cases where the set class/bank weren't an exact
match. Additionally, RegBankSelect was also expecting a register bank
to be set on the register, not a class.

This is much stricter than regular copies so relax this behavior. This
now allows these 2 cases:

1. Source register has either class or bank, and the result does not
2. Source register has a register class, and the result is a register
with a matching bank.

This should avoid needing some kind of special handling to avoid
violating this constraint when folding copies.
llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
llvm/lib/CodeGen/MachineVerifier.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-assert-zext.mir [new file with mode: 0644]
llvm/test/MachineVerifier/test_g_assert_sext_register_bank_class.mir
llvm/test/MachineVerifier/test_g_assert_zext_register_bank_class.mir