[llvm] [RDF] Create phi nodes for clobbering defs (PR #123694)

Yashas Andaluri via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 11:22:10 PST 2025


yandalur wrote:

Thanks @kparzysz for taking a look. I was working on updating the RDF copy propagation pass to find more opportunities for copy propagation.
During this process, I encountered an issue where the source register of the copy has a clobbered reaching def. llvm/test/CodeGen/Hexagon/rdf-copy-clobber.mir lit test has the case that hit the issue.

The test has a copy from r28 to r27 at [L107](https://github.com/llvm/llvm-project/pull/123694/files#diff-ccc46439c19ddb1342b8727a2c59505067e2e6c47a0c5711fb7b0a801072fe20R107) 

When looking for the reaching defs of r28 at [L123](https://github.com/llvm/llvm-project/pull/123694/files#diff-ccc46439c19ddb1342b8727a2c59505067e2e6c47a0c5711fb7b0a801072fe20R123) using the RDF graph, only [L106](https://github.com/llvm/llvm-project/pull/123694/files#diff-ccc46439c19ddb1342b8727a2c59505067e2e6c47a0c5711fb7b0a801072fe20R106) was found. 
I did not find any existing information graph that can be used to identify the clobbered $r28 from the back-edge of the loop. The clobbered reaching def information is needed to skip this case for copy propagation.

I'm only adding phi nodes for registers that have atleast one non-clobbered reaching def to the block. This reduces the number of new phi nodes created.

I was not able to find any relevant patch from git log. Is there a better alternative for resolving this clobbered reaching def issue?


https://github.com/llvm/llvm-project/pull/123694


More information about the llvm-commits mailing list