This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Relax handling of G_ASSERT_* with source register classes
ClosedPublic

Authored by arsenm on Apr 15 2022, 9:14 AM.

Details

Summary

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.

Diff Detail

Event Timeline

arsenm created this revision.Apr 15 2022, 9:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 9:14 AM
arsenm requested review of this revision.Apr 15 2022, 9:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 9:14 AM
Herald added a subscriber: wdng. · View Herald Transcript
paquette added inline comments.Apr 15 2022, 1:20 PM
llvm/test/MachineVerifier/test_g_assert_zext_register_bank_class.mir
32

maybe we should also test like

%nothing64:_(s64) = G_IMPLICIT_DEF
%dst_32:_(s32) = G_ASSERT_ZEXT %nothing64, 4
arsenm added inline comments.Apr 21 2022, 5:43 PM
llvm/test/MachineVerifier/test_g_assert_zext_register_bank_class.mir
32

That's already illegal and tested in test_g_assert_zext

This revision is now accepted and ready to land.Apr 21 2022, 6:05 PM