This is an archive of the discontinued LLVM Phabricator instance.

[IRSim] Adding commutativity matching to structure checking
ClosedPublic

Authored by AndrewLitteken on Sep 8 2020, 11:36 AM.

Details

Summary

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

Diff Detail

Event Timeline

AndrewLitteken created this revision.Sep 8 2020, 11:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2020, 11:36 AM
jroelofs added inline comments.
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
426

Can these be ArrayRefs instead of SmallVector&s?

AndrewLitteken marked an inline comment as done.Sep 14 2020, 10:11 AM

Changing some SmallVectors to ArrayRefs.

This revision is now accepted and ready to land.Sep 14 2020, 12:54 PM