The patch is to solve the performance problem described in PR27827.
Register coalescing sometimes cannot remove a copy because of interference. But if we can move the copy a little bit, like to its predecessors, we may find out that some of the copies moved to the predecessors are redundent. The patch handle a typical case like this:
A = B ... / \ / BB2: B = A
If B = A in BB2 has a reversed copy in BB0, B = A will be redundent if the execution goes through the path from BB0 to BB2. We may remove the so called partial redundency by moving B = A to BB1.
The correctness requirement for such transformation is:
- A in B = A in BB2 is defined by the reversed copy A = B in BB0.
- No B is referenced from the start of BB2 to B = A.
- No B is defined from A = B to the end of BB0.
It is ok for BB0 to have multiple successors, but we require that BB1 has only one successor so we always move a copy to a colder place.
I got 1~2% improvement on an internal benchmark. I tested spec2000 and the performance was flat.