This patch adds two folds. One for a repeated xor (e.g. xor(xor(x, a), a)) and one for a repeated trunc (e.g. trunc(trunc(x))).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Arithmetic/IR/ArithmeticCanonicalization.td | ||
---|---|---|
117 ↗ | (On Diff #396558) | We should match any constant instead of directly Arith_ConstantOp, but more importantly I think that a reassociation like A(B(x, c0), c1) = A(x, B(c1, c2)) deserves to be generic and implemented with a "reassociative" trait. |
147 ↗ | (On Diff #396558) | Seems like this could be a fold? |
This more focused version LGTM. The "Reassociative" trait suggested by Mehdi is still interesting as a separate patch.
Can you please address these? Looks like these were missed by other reviewers.
mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp | ||
---|---|---|
866–867 | We shouldn't be checking things that are guaranteed by the op's verifier. It's unnecessary and would lead to a bloat if done consistently. | |
875–876 | This is leading to a redundant call to getDefiningOp -- there isn't a benefit to using matchPattern here. Just use getDefiningOp<arith::TruncIOp>() -- eliminates an extra check. |
We shouldn't be checking things that are guaranteed by the op's verifier. It's unnecessary and would lead to a bloat if done consistently.