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

Lawrence Benson via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 07:16:02 PDT 2024


lawben wrote:

@arsenm I'm struggling a bit with the GlobalISel implementation, as I don't have experience with it. I've created a `GenericOpcode` for it in `GenericOpcodes.td` as follows:

```
// Generic masked compress.
def G_MCOMPRESS: GenericInstruction {
  let OutOperandList = (outs type0:$dst);
  let InOperandList = (ins type1:$vec, type2:$mask);
  let hasSideEffects = false;
}
```

and I've added 

```
def : GINodeEquiv<G_MCOMPRESS, masked_compress>;
``` 

to `SelectionDAGCompat.td` by following some examples/tutorials. 

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>)
``` 

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.

Could you maybe point me in the right direction to continue here? I'm not really sure how to continue / what to actually implement for GIsel. 

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


More information about the llvm-commits mailing list