[llvm] [InstCombine] Simplify and/or by replacing operands with constants (PR #77231)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 06:13:52 PST 2024


nikic wrote:

> I am not sure that it is correct to decompose (A ^ B) | Y into ((A | Y) ^ (B | Y)) | Y if Y may be an undef (See the alive2 proof).

I don't really understand how this is related to your patch.

> As the current implementation is too conservative in the one-use checks, I cannot remove other existing hard-coded simplifications if they involves more than two instructions (e.g, A & ~(A ^ B) --> A & B).

I think there are quite a few patterns you could drop that are currently *missing* one-use checks. For example https://github.com/llvm/llvm-project/blob/3c246efd04210af56ab6ce960b98283ec5bc7c30/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L3543-L3545 and some of the above fails to check one-use on the and.

But it's fine to do this in separate step, with extra test coverage for multi-use if necessary.

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


More information about the llvm-commits mailing list