This is an archive of the discontinued LLVM Phabricator instance.

[Polly][DeLICM] Use Known information when comparing Occupied and Written.
ClosedPublic

Authored by Meinersbur on Apr 13 2017, 9:50 AM.

Details

Summary

Do not conflict if a write writes the same value as already known.

This change only affects unit tests, but no functional changes are
expected on LLVM-IR, as no Known information is yet extracted and
consequently this functionality is only triggered through unit tests.

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Apr 13 2017, 9:50 AM
grosser edited edge metadata.Apr 14 2017, 10:21 AM

Hi Michael,

I really enjoy reviewing these small size patches. Thanks a lot. In general the content of the patch looks great, but I feel the operations you use could possibly simplified (see below). I would be interested in your opinion.

lib/Transform/DeLICM.cpp
684 ↗(On Diff #95147)

This comment does not seem to be in line with what actually happens. Where do we:

  • "remove the writes that write into Proposed.Unused"
  • "see wheather the written value is already in Proposed.Known"

It seems what we do is:

  • Intersect the Existing Writes with the Currently Occupied values to find the set of possibly conflicting writes.
  • See if the set of possibly conflicting writes only contains known values by checking if it is a subset of ProposedFixedKnown.
707 ↗(On Diff #95147)

This seems more complex as needed. For me the following code also works:

auto ProposedFixedDefs =                                                     
    convertZoneToTimepoints(Proposed.Occupied, true, false);                 
auto ProposedFixedKnown =                                                    
    convertZoneToTimepoints(Proposed.Known, isl::dim::in, true, false);      
auto ExistingConflictingWrites =                                             
    Existing.Written.intersect_domain(ProposedFixedDefs);                    
                                                                             
if (!ExistingConflictingWrites.is_subset(ProposedFixedKnown)) {

Some of the later code can -- if needed at all -- be sunk into the "if (OS)".

Or did I miss something?

738 ↗(On Diff #95147)

AFAIU this is equivalent to the following code:

auto ProposedWrittenDomain = Proposed.Written.domain();                      
auto ExistingAvailableDefs =                                                 
    convertZoneToTimepoints(Existing.Unused, true, false);                   
auto KnownIdentical = Existing.Known.intersect(Proposed.Written);            
if (!ProposedWrittenDomain.is_subset(                                        
        ExistingAvailableDefs.unite(KnownIdentical.domain()))) {

which is _very_ similar to the earlier code, a lot more concise, and does not even need an expensive subtract. I just now realized that we can avoid the subtract by computing the union of the KnownIdenticalSet with the ExistingAvailableDefs, rather than subtracting it beforehand. The same appraoch likely also applies to D32025.

Meinersbur marked 2 inline comments as done.Apr 25 2017, 7:13 AM
Meinersbur added inline comments.
lib/Transform/DeLICM.cpp
684 ↗(On Diff #95147)

In my understanding this is exactly what the code below does:

"remove the writes that write into Proposed.Unused"

auto ExistingConflictingWrites = Existing.Written.intersect_domain(ProposedFixedDefs);

ProposedFixedDefs = Proposed.Occupied, i.e. the intersect removes Proposed.Unused.

"see wheather the written value is already in Proposed.Known"

auto SomeWrittenVal = ProposedFixedKnown.intersect(ExistingConflictingWrites);

SomeWrittenVal will contain matched pairs where the value written is the same as the value already known. The final condition is whether all writes overlapping with Proposed.Occupied has a match.

707 ↗(On Diff #95147)

Added a test case where the difference between your implementation and mine matters.

We could simplify to your version if we assume that Existing.Written contains at most one value (assert(isl_union_map_is_single_valued(Existing.Written))). I want to leave the possibility open to properly handle PHINodes.

738 ↗(On Diff #95147)

Both implementations do the same. Mine has the union the intersection and adds the unknown value to both arguments such that it survives the intersection. This can indeed be made simpler by doing the union afterwards. I opted to your version (There was a`convertZoneToTimepoints` call missing and I introduced an intermediate result variable IdenticalOrUnused).

Meinersbur updated this revision to Diff 96554.Apr 25 2017, 7:15 AM
Meinersbur marked 2 inline comments as done.
  • Rebase to r301301
  • Adressed Tobias' comments.
Meinersbur retitled this revision from [Polly][DeLICM] Use Known information when comparing Occupied and Written. NFC. to [Polly][DeLICM] Use Known information when comparing Occupied and Written..Apr 25 2017, 7:17 AM
Meinersbur edited the summary of this revision. (Show Details)
grosser accepted this revision.Apr 25 2017, 7:22 AM

Nice, this LGTM.

This revision is now accepted and ready to land.Apr 25 2017, 7:22 AM
This revision was automatically updated to reflect the committed changes.