[llvm-dev] DAGCombiner folds (xor (and x, y), y) -> (and (not x), y). Can I do the reverse for a target?

Roel Jordans via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 23 08:54:39 PDT 2016


Hi Assem,

I believe you can do this with a pattern node in tablegen.  That allows 
you to match a pattern of operations and replace it with some new 
operations.

Something like the following might work:

def : Pat<(and (xor REGS:$x, (i32 -1), REGS:$y),
           (INST1 REGS:$x (INST2 REGS:$y, ...))>;

The first part will do the match, so it should be in normal LLVM 
operations, the second part should be your MI pattern to insert.

Cheers,
  Roel

On 23/06/16 17:32, Assem Bsoul via llvm-dev wrote:
> I am not sure what is the format for matching this (and (xor x, -1), y)
> and generating 2 machine instructions? can you please help!
>
> Thanks,
> Assem
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>


More information about the llvm-dev mailing list