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

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

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