Page MenuHomePhabricator

AMDGPU/SILoadStoreOptimizer: Improve merging of out of order offsets
Needs ReviewPublic

Authored by tstellar on Aug 8 2019, 12:50 PM.



This improves merging of sequences like:

store a, ptr + 4
store b, ptr + 8
store c, ptr + 12
store d, ptr + 16
store e, ptr + 20
store f, ptr

Prior to this patch the basic block was scanned in order to find instructions
to merge and the above sequence would be transformed to:

store4 <a, b, c, d>, ptr + 4
store e, ptr + 20
store r, ptr

With this change, we now sort all the candidate merge instructions by their offset,
so instructions are visited in offset order rather than in the order they appear
in the basic block. We now transform this sequnce into:

store4 <f, a, b, c>, ptr
store2 <d, e>, ptr + 16

Another benefit of this change is that since we have sorted the mergeable lists
by offset, we can easily check if an instruction is mergeable by checking the
offset of the instruction that becomes before or after it in the sorted list.
Once we determine an instruction is not mergeable we can remove it from the list
and avoid having to do the more expensive mergeablilty checks.

Event Timeline

tstellar created this revision.Aug 8 2019, 12:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2019, 12:50 PM
arsenm added inline comments.Aug 12 2019, 1:09 PM

Why std::list?


Weird format


Don't you know which is first from which was encountered first?