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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 5 09:27:54 PDT 2021


craig.topper added a comment.

In D109273#2984072 <https://reviews.llvm.org/D109273#2984072>, @craig.topper wrote:

> In D109273#2983998 <https://reviews.llvm.org/D109273#2983998>, @pengfei wrote:
>
>> 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;
>
> In matchVPTERNLOG, why can’t we just check if each input is a single use xor with -1 after calculating the immediate and then change then change the mask appropriately. No new nodes needed

Sorry it should probably be in tryVPTERNLOG.


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