Looking up constant offset for this intrinsic is done during RegBankSelect
so the constant might find itself behind a copy from sgpr to vgpr.
Details
Diff Detail
Event Timeline
llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp | ||
---|---|---|
51 | This shouldn't add a second match pattern for a copy. That should be hidden away somehow. In this case I'd say the problem is regbankselect isn't picking the correct bank for the constant in the first place since we don't consider the users right now. We've been working around this on a case by case basis, but I think we should try to fix this. Also arguably mi_match should look through copies, although in the presence of cross reg bank copies that's more questionable |
I revisited this again to try to find a way to eliminate these cross reg bank copies but I wasn't able to find an efficient solution. Looking through uses of dst of G_CONSTANT at the time of selecting a bank for that instruction does not help since RegBank is not working backwards.
One idea that does work is to instead of making a cross reg bank copy to a constant to simply recreate a new G_CONSTANT with required bank (change is in RegBankSelect::repairReg). This can help with the current problem but produces less optimal solutions in a lot of tests. In some cases instead of an SGPR, an extra VPGR will be used instead. And in cases where same constant needs to be used as both SGPR and VGPR there can also be an additional s/v_mov instruction.
Here we can at least hide copy check inside matcher.
clang-tidy: warning: 'auto MI' can be declared as 'auto *MI' [llvm-qualified-auto]
not useful