This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Add check to recompute merge-able instructions
Needs RevisionPublic

Authored by dstuttard on Mar 6 2020, 6:50 AM.

Details

Summary

When SILoadStoreOptimizer merges instructions, if an instruction from a
different set of merge-able instructions is moved, this invalidates the yet to be
processed list. This change can detect this situation and forces a re-computation
of the yet to be processed instructions.

This is likely to be a relatively rare occurrence, so the extra overhead of the
computation is negligible.

Change-Id: Ie6d26596fea2af03b0dd5e029d74281079930ad2

Diff Detail

Event Timeline

dstuttard created this revision.Mar 6 2020, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2020, 6:50 AM

I encountered this issue with a test shader I was looking at. I did manage to create a reproducer, but a different fix to the triviallyDisjoint function meant that it stopped happening.
However, I still think the situation may occur, hence putting this change up for review.

If the consensus is that it is valid, I can try to create a test case for it.

dstuttard updated this revision to Diff 248756.Mar 6 2020, 9:02 AM

Formatting fixes

Added more reviewers - anyone got an opinion on this one.

I'm now wondering if it might be possible to use a different approach that doesn't use iterators. Any thoughts?

How would it invalidate the list? Isn't the analysis of which instructions can be moved done one list at a time?

How would it invalidate the list? Isn't the analysis of which instructions can be moved done one list at a time?

My impression (perhaps incorrect) was that the original code built a list of lists of instructions in a block that can be optimised.
My change keeps a list of instructions that have been moved when processing one list - and if those instructions are found in another unprocessed list it sets an invalid flag. This forces a re-computation of the un-optimised instructions thus making the iterators valid again. I thought this wouldn't be too expensive as I suspect this very rarely happens (hence the reason that we haven't picked up the problem before now).

arsenm requested changes to this revision.Jul 6 2020, 1:20 PM

Is this still necessary?

This revision now requires changes to proceed.Jul 6 2020, 1:20 PM