I would like to discuss few points to use RDF to extend register remat scope. Mr. Krzysztof and I have started discussion this on private mail. But I think now it would be better to include community.
Interested community member kindly previous discussion (at the end of mail) before starting here.
After analyzing if RDF can be used for solving Remat, we think that problem with RDF is that since it is post-RA, rematable register values also will be spilled and all its use will be surrounded with load-spill instructions. So identifying rematable sequence of instructions will be possible with RDF but its uses will not be associated with these instructions with any use-def chain because live-ranges have been split by spill-relaod.
One solution that I can think of is that during RA when a spill code is inserted , it can add a dummy instruction as a maker that can be used after post-RA to identify live-range (reg value) which was spilled and which instructions is using it after reloading (i.e where to use remated value). The post-RA pass can use RDF to construct remat sequence and use it and remove spill/restore as well as the marker instruction (dummy) inserted during the spill code generation. Is this possible with out changing much of Spill code framework? What all steps are required to add such a dummy /debug instruction at MIR ?
In case if RDF graph is not useable for this problem then simply use-def chain on MIR can be traversed in bottom up manner to identify remat instruction sequence.
Please share your thoughts.