This is an archive of the discontinued LLVM Phabricator instance.

[IRSim] Adding support for isomorphic predicates
ClosedPublic

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

Details

Summary

Some predicates, can be considered the same as long as the operands are flipped. For example, a > b gives the same result as b > a. This maps instructions in a greater than form, to their appropriate less than form, swapping the operands in the IRInstructionData only, allowing for more flexible matching.

Tests:

  • llvm/test/Transforms/IROutliner/outlining-isomorphic-predicates.ll
  • llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Diff Detail

Event Timeline

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

Should equality and inequality also be canonicalized? Maybe your hash function can be tweaked to use an operation that's commutative specifically in that case.

jroelofs added inline comments.Sep 10 2020, 2:34 PM
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
86

Oh, I see that's being handled here: https://reviews.llvm.org/D87311

jroelofs accepted this revision.Sep 14 2020, 1:26 PM

LGTM

llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
135–136

Since we generally don't build with exceptions turned on, it makes more sense to talk about what's allowed/not in the function's contract, rather than mentioning that assertion failures "throw".

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

A few things changed just enough since OperTypes was removed, so updating the diff to reflect this.

This revision was automatically updated to reflect the committed changes.