This patch simplifies the cmpi Standard dialect operation when its operands are identical and it replaces it with a constant representing the outcome of the comparison.
This looks like it should be part of the fold method instead.
Can you use proper operand accessors instead of this? (.lhs()/.rhs())
Please avoid the use of SSA value names inside of check lines, use captures instead.
The input attributes to fold are operands that are known to be constant, i.e. you can still use the operands directly from the operation. If you are getting lit failures, that is due to something else. (e.g. tests being broken by better folding that changed the expected output)
nit: Can you use BoolAttr::get here instead? BoolAttr is a utility wrapper around i1 IntegerAttr.
Can you trim out all of the unnecessary operations here? You should be able to test these cases with just the cmpi and function arguments.
Can you make sure to add tests for each of the other cases that you are folding?
Thanks. LGTM after resolving the last few comments.
This isn't possible, the operands to an operation are always valid. You only have to check null when accessing attributes from the operands parameter, as a null Attribute means that the operand isn't constant.
nit: The general style is to have this before not after.
nit: These CHECK-NOTS can be simplified to just CHECK-NOT: cmpi