This is an archive of the discontinued LLVM Phabricator instance.

[IRSim] Check largest sections first when analyzing similarity
ClosedPublic

Authored by AndrewLitteken on Dec 5 2022, 8:53 AM.

Details

Summary

When we check for similarity, right now there is no order to how it is checked, except for via the suffix tree ordering.

We can reduce how much structural analysis we perform by checking the the regions in decreasing size. In doing so, we know that if two large sections match, each of their contained regions also match. This allows us to skip the structural checking for each smaller section. IT does require that we use the large regions as a "bridge" to create the canonical mapping between the two regions.

This reduces compile time significantly for some benchmarks. It will not perform as well for programs with many small items.

Diff Detail

Event Timeline

AndrewLitteken created this revision.Dec 5 2022, 8:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 8:53 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
AndrewLitteken requested review of this revision.Dec 5 2022, 8:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 8:53 AM

exclude parent patch code

Can we add a statistic which calculates the average size of an outlinable region?

AndrewLitteken added inline comments.Dec 6 2022, 10:43 AM
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
1177

Oops, I missed these. I'll be sure to remove this.

paquette added inline comments.Dec 6 2022, 10:45 AM
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
859
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
1126

is there a call to empty() or something you could use here?

1148

does this need to be a copy? or could you use a reference?

1178

remove debug dumping code?

1254

Could this just be auto IdxIt = ...?

Also IdxIt could probably use a more descriptive name?

1259

I think CandA.getStartIdx() and CandA.getEndIdx() can be hoisted out of the loop into variables.

1273

The start index + end index for CandB can be hoisted out of this loop too.

1292

These could probably both be declared with auto too?

This revision is now accepted and ready to land.Mar 17 2023, 10:48 AM
This revision was landed with ongoing or failed builds.Mar 20 2023, 4:28 PM
This revision was automatically updated to reflect the committed changes.