We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1f0e68 commit d1d3a1aCopy full SHA for d1d3a1a
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -896,6 +896,18 @@ OpFoldResult arith::AndIOp::fold(FoldAdaptor adaptor) {
896
if (Value result = foldAndIofAndI(*this))
897
return result;
898
899
+ /// and(a, or(a, b)) -> a
900
+ for (int i = 0; i < 2; i++) {
901
+ auto a = getOperand(1 - i);
902
+ if (auto orOp = getOperand(i).getDefiningOp<arith::OrIOp>()) {
903
+ for (int j = 0; j < 2; j++) {
904
+ if (orOp->getOperand(j) == a) {
905
+ return a;
906
+ }
907
908
909
910
+
911
return constFoldBinaryOp<IntegerAttr>(
912
adaptor.getOperands(),
913
[](APInt a, const APInt &b) { return std::move(a) & b; });
0 commit comments