[llvm] [AArch64][GlobalISel] Bitcast and Build Illegal G_CONCAT_VECTOR Instructions (PR #96492)

David Green via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 04:40:04 PDT 2024


davemgreen wrote:

> I don't mean more obvious in the sense that there's a correct alternative, but from the perspective of someone who's not been looking at this problem deeply, a solution like this seems un-intuitively specific. That's not to say that it's wrong, but we just need some clearer documentation about what the fundamental issue is. At some point someone is going to need to understand the reasons in future.
> 
> Just as an example approach: "why can't we just transform `concat <4 x s8>, <4 x s8>, <4 x s8>, <4 x s8>` into a 2 source concat of `<8 x s8>`?"

Ah, I was hoping there was some obvious method we could use here. I'm not sure splitting the concat in half would help if it still has a v4i8->v8i8 concat?

To try and answer the question here, as far as I understand we need to do something with the concats of illegal types, especially those that have smaller than legal operands. We eventually want to turn them into insert elements, inserting the v4i8 into the full v16i8 vector.

There are probably several ways to go about that, #85047 tried to treat them like legalization artefacts and fold concat(bitcast,..) into buildvector(..). It needed to check for implicit_def too though because they can be present as part of the shuffle trees llvm would create. It would seem that if the concat is not already simplified we would want to turn any v4i8 concat into a buildvector though, hence this patch which changes any concat of smaller types under AArch64 into bitcast(buildvector). We probably can't be sure this would fix all the cases but it seems to work for the ones we have tried.

https://github.com/llvm/llvm-project/pull/96492


More information about the llvm-commits mailing list