Prior to this patch the canonicalization pattern that turns reinterpret_cast(extract_strided_metadata) into cast was only applied when all the input operands of the reinterpret_cast are exactly all the output results of the extract_strided_metadata.
This missed simplification opportunities when the values would have hold the same constant values, but yet, come from different actual values.
E.g., prior to this patch, a pattern of the form:
%base, %offset = extract_strided_metadata %source : memref<i16> reinterpret_cast %base to offset:[0]
Wouldn't have been simplified into a simple cast, because %offset is not directly the same value object as 0.
This patch teaches this pattern how to check if the constant values match what the results of the extract_strided_metadata operation would have hold.
Note: This patch will be helpful to keep nice MLIR outputs when I push the patch to do the forwarding of statically known information as part of a folding of extract_strided_metadata.
We'll probably want these methods to be part of an interface.
ViewLikeInterface could have been a candidate but extract_strided_metadata doesn't conform to it, so we likely will need to introduce something else.
For now, I just added the methods where I needed them.