This patch add an optimization to hoist and merge multiple register copies among BBs as illustrated below.
BB1-------- BB1-------- | .. | | .. | | | | mr Y, X | | bcc | | bcc | ----------- ----------- / \ / \ BB--------- BB--------- BB--------- BB--------- | mr Y, X | | mr Y, X | => |(erased) | |(erased) | | .. | | .. | | .. | | .. | ----------- ----------- ----------- -----------
After the optimization, a BB will be erased if the BB becomes empty (i.e. only includes an unconditional branch).
This lambda looks more like isSameRegOperation. From here we don't know they are both COPY Operation or not. It looks to me that is implied from the calling site. In that case, I would rename it to expression what it really does. Or we could change the implementation to match the current name. Either way is fine, as long as the name and what it does is consistent. And an assertion to make sure you only get COPY operation for this lambda may be necessary.