[Mlir-commits] [mlir] [MLIR][Arith] add and(a, or(a, b)) folder (PR #138998)
William Moses
llvmlistbot at llvm.org
Tue Jun 3 15:24:40 PDT 2025
================
@@ -896,6 +896,18 @@ OpFoldResult arith::AndIOp::fold(FoldAdaptor adaptor) {
if (Value result = foldAndIofAndI(*this))
return result;
+ /// and(a, or(a, b)) -> a
+ for (int i = 0; i < 2; i++) {
----------------
wsmoses wrote:
so the reason that might be hard is that we need both the original operand, and also the "other" operand. In the loop form that can be written as get operand[i] and operand[1-i], and/or operand[i] and i == 0 ? operand[1] : operand[0]. Not sure how to do that as a single foreach iterator
https://github.com/llvm/llvm-project/pull/138998
More information about the Mlir-commits
mailing list