This is an archive of the discontinued LLVM Phabricator instance.

[MachinePipeliner] Fix a bug in write-after-read scheduling
Needs ReviewPublic

Authored by alonkom on Jul 12 2023, 5:52 AM.

Details

Summary

When computing the early/late start/end cycle only the case of loop-carried-dependence where the read comes before the write is handled.
This code guarantees they will be scheduled at the same stage, no more than II cycles apart.
This didn't work properly when the write occurs before the read, even though they may be loop-carried dependent.
For example:

a[idx] = 1;
b[idx] = long_compute_chain(a[idx + 1]);

In this case, where the write a[idx], comes before the read a[idx+1], the read cannot be scheduled more than II cycles from the write, as the write may store new data that should have been read already in previous iteration.

Unfortunately, I'm working on an out-of-tree target, and couldn't create a lit test of this case.

Diff Detail

Event Timeline

alonkom created this revision.Jul 12 2023, 5:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 5:52 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
alonkom requested review of this revision.Jul 12 2023, 5:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 5:52 AM

In your test case, does the addLoopCarriedDependences function add a Barrier edge between the load and store? If so, that should prevent the case described in the comment.