[llvm] [InstCombine] Fold Xor with or disjoint (PR #105992)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 25 13:09:05 PDT 2024
================
@@ -4056,6 +4056,25 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
return nullptr;
}
+static Instruction *foldXorToOr(BinaryOperator &I,
+ InstCombiner::BuilderTy &Builder) {
+ assert(I.getOpcode() == Instruction::Xor);
+ Value *A, *B, *C, *D, *E;
+
+ // ((select C, A, B) | E) ^ D) -> (select C, A ^ D, B ^ D) | E)
+ if (match(&I,
----------------
elhewaty wrote:
move this condition to the `InstCombinerImpl::visitXor` function.
I can help with the condition, but I let you think.
further hints:
I think I should refer to @dtcxzyw to double-check my suggestions:
- I think the issue was about matching constants in place of `A`, `B`, and `D`, so It's better to use `m_APInt` instead.
https://github.com/llvm/llvm-project/pull/105992
More information about the llvm-commits
mailing list