Convert arith.cmpi to the canonical form with constants on the right side
to simplify further optimizations and open more opportunities for CSE.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Change in sccp-structured test is suspicious, I'm not sure what this test is supposed to check and why this change is needed (scf.while didn't get removed without it). Can someone help me with this?
mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp | ||
---|---|---|
1337 | wil -> will | |
1337 | Side note: The other invertPredicate should, I believe, be renamed to negatePredicate -- it's negating, not inverting. (<= would become > -- it's not just == and !=). | |
1345 | auto -> Pred | |
1360 | This can now be updated (simplified). Since you've moved the constant to the right, you only need to check for the lhs not being a constant! If the lhs is a constant, the rhs will guaranteed to be a constant at this stage given your change above. | |
mlir/test/Dialect/Arithmetic/canonicalize.mlir | ||
130 | Nit: Full stop at the end. |
LGTM - this is a welcome change. You can eliminate an additional check in the folder further below given this canonicalization; please see comment below.
LGTM - please expand the commit summary to more importantly mention that this puts the ops in a canonical form in the presence of one constant. CSE and other ease in optimizing/checking follows from that.
mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp | ||
---|---|---|
1363 | Nit: Please punctuate appropriately. (semi-colon or full stop after side.) |
wil -> will