[PATCH] D109273: [X86] Fold (and (or (xor X, -1), Y), Z) -> PTERNLOG Z, Y, X, 0xD0

Pengfei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 4 19:37:31 PDT 2021


pengfei added a comment.

In D109273#2983658 <https://reviews.llvm.org/D109273#2983658>, @RKSimon wrote:

> We do most TERNLOG matching inside X86DAGToDAGISel::tryVPTERNLOG (which has a 'FIXME: Handle inverted inputs?' comment) - might it be possible to handle this there?

As far as I learnt it, it's hard to do so. We have 3 difficulties:

1. We need a new `ORNP` node for pre-processing and the logic in `tryVPTERNLOG`, but `ORNP` isn't a canonical node like `AND`, `ANDNP` etc. that can be used for permutation;
2. Even we have a `ORNP`, we have to change the logic to prioritise `ORNP` over other nodes and ignore the permutation math;
3. Even we achieved 1 and 2, we have to change `matchVPTERNLOG`, because it assumes the operands are commutable while it's not true for this combine;


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109273/new/

https://reviews.llvm.org/D109273



More information about the llvm-commits mailing list