[llvm] [Codegen] Remove redundant instruction using machinelateCleanup (PR #139716)

Rohit Aggarwal via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 3 02:39:38 PDT 2025


rohitaggarwal007 wrote:

The value of upper bit of $rax should not matter.

If the there is no redefinition of eax or rax between the candidate duplicate instruction and source instruction, there it is safe to remove the duplicate instruction. The value for upper bits of $rax will remain the same.

We have to just provide that there is not definition of rax or eax between the source and candidate instruction.

As per my understanding, It should be already be implemented in the pass but I am not able to find the logic for the same.
There is a use of `MBBDefs.hasIdentical(DefedReg, &MI)` api but not sure that it check for redefinition between them.

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


More information about the llvm-commits mailing list