[llvm] [LLVM] Add `llvm.masked.compress` intrinsic (PR #92289)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 07:26:24 PDT 2024


arsenm wrote:

> def : GINodeEquiv<G_MCOMPRESS, masked_compress>;

This will help you with step 3 (select), but some work will be needed to define some legalizer rules (and regbankselect for the legal cases) 



> 
> However, I cannot get any further with this, as other instructions "fail" in GlobalISel before I even get to my masked compress. As I understand, AArch64 has one of the more sophisticated GISel implementations, but even with that, I'm getting errors like:
> 
> ```
> LLVM ERROR: unable to legalize instruction: %1:_(<4 x s1>) = G_TRUNC %2:_(<4 x s16>)
> ```
> 

AArch64 is fairly incomplete on vectors last I checked. It's still possible to write a MIR only test that shows your expansion without handling everything 

> This truncation is unavoidable in my case, as I need a `<N x s1>` mask, which is not legal in itself.
> 
> Also, my current SelectionDAG-based implementation has a generic expand path in `TargetLowering.cpp` for all tagets that don't support it natively. I cannot seems to find a target-independent code path for GIsel in which I could add some logic to expand this.

This would be in LegalizerHelper, conditionally called depending on the legalizer rules defined by the target (e.g. https://github.com/llvm/llvm-project/blob/c675a58edec6d1a876a0d0e7d261f74764855b38/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp#L920) 


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


More information about the llvm-commits mailing list