Certain instructions, such as adds and multiplies can have the operands flipped and still be considered the same. When we are analyzing structure, this gives slightly more flexibility to create a mapping from one region to another. We can add both operands in a corresponding instruction to an operand rather than just the exact match. We then try to eliminate items from the set, until there is only one valid mapping between the regions of code.
We do this for adds, multiplies, and equality checking. However, this is not done for floating point instructions, since the order can still matter in some cases.
Tests:
- llvm/test/Transforms/IROutliner/outlining-commutative-fp.ll
- llvm/test/Transforms/IROutliner/outlining-commutative.ll
- llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp
Can these be ArrayRefs instead of SmallVector&s?