[llvm] [InstCombine] Fold Xor with or disjoint (PR #105992)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 25 13:32:37 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:

Will this check be profitable if the `or` has more than one use? 🤔

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


More information about the llvm-commits mailing list