[llvm] [InstCombine] Simplify and/or by replacing operands with constants (PR #77231)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 09:13:09 PST 2024
================
@@ -2179,6 +2179,57 @@ foldBitwiseLogicWithIntrinsics(BinaryOperator &I,
}
}
+// Try to simplify X | Y by replacing occurrences of Y in X with 0.
+// Similarly, simplify X & Y by replacing occurrences of Y in X with -1.
+// Return the simplified result of X if successful, and nullptr otherwise.
+static Value *simplifyAndOrWithOpReplaced(Value *X, Value *Y, bool IsAnd,
+ InstCombinerImpl &IC,
+ unsigned Depth = 0) {
+ if (isa<Constant>(X) || X == Y)
+ return nullptr;
+
+ auto RecursivelyReplaceUses = [&](Instruction::BinaryOps Opcode, Value *Op0,
+ Value *Op1) -> Value * {
----------------
dtcxzyw wrote:
Done.
https://github.com/llvm/llvm-project/pull/77231
More information about the llvm-commits
mailing list