[Mlir-commits] [mlir] [MLIR][Arith] add and(a, or(a, b)) folder (PR #138998)
Mehdi Amini
llvmlistbot at llvm.org
Tue Jun 3 15:09:24 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++) {
+ auto a = getOperand(1 - i);
+ if (auto orOp = getOperand(i).getDefiningOp<arith::OrIOp>()) {
+ for (int j = 0; j < 2; j++) {
+ if (orOp->getOperand(j) == a) {
+ return a;
+ }
----------------
joker-eph wrote:
```suggestion
if (orOp->getOperand(j) == a)
return a;
```
https://github.com/llvm/llvm-project/pull/138998
More information about the Mlir-commits
mailing list