The function merger should be able to handle small differences if the two functions are still equivalent.
This patch, as the title suggests, enables the function merger to handle simple operand reordering for commutative binary operators.
For example:
mul nsw i32 3, %a
should be equivalent to
mul nsw i32 %a, 3
This check is handled by the FunctionComparator. Whenever it says that two functions are equivalent, the MergeFunctions pass is able to merge them.
I've added a simple unit test to exercise this change. All unit tests pass as expected.
- Rodrigo Rocha
Please run the added code through clang-format.