This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/GlobalISel: Fix handling of G_ANYEXT with s1 source
ClosedPublic

Authored by arsenm on Feb 20 2020, 2:04 PM.

Details

Summary

We were letting G_ANYEXT with a vcc register bank through, which was
incorrect and would select to an invalid copy. Fix this up like G_ZEXT
and G_SEXT. Also drop old code to fixup the non-boolean case in
RegBankSelect. We now have to perform that expansion during selection,
so there's no benefit to doing it during RegBankSelect.

Diff Detail

Event Timeline

arsenm created this revision.Feb 20 2020, 2:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2020, 2:04 PM
foad added a comment.Feb 21 2020, 7:34 AM

Looks OK but I'm a bit out of my depth so I'd prefer someone else to take a look too.

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
2159

This would be clearer folded into its only use on line 2180.

2205

Typo "selcet".

llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-anyext.mir
25

Only vgpr0 is live-in, but I guess this is harmless?

28

Why do we get the extra copy? Is this just more cruft that should be cleaned up by a later pass?

arsenm marked an inline comment as done.Feb 21 2020, 9:38 AM
arsenm added inline comments.
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-anyext.mir
28

Since we told the generic infrastructure this needs to break into 2 32-bit pieces, it created new 32-bit registers for us which we use. We end up with a copy to use it. I think letting the generic code sometimes create the split is just more trouble than it's worth, so I'm considering ripping that out

arsenm marked an inline comment as done.Feb 21 2020, 9:41 AM
arsenm added inline comments.
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-anyext.mir
28

End to end, PeepholeOptimizer and/or the RegisterCoalescer can take care of the copy. However I do think the combiner passes in GlobalISel should start taking care of these. Right now there's plenty of code which tries to skip through trivial copies as if they don't exist

This revision is now accepted and ready to land.Mar 15 2020, 10:04 PM