================
@@ -1262,6 +1262,18 @@ bool MachineLICMBase::IsProfitableToHoist(MachineInstr 
&MI,
     return false;
   }
 
+  // If we have a COPY with other uses in the loop, hoist to allow the users to
----------------
bjope wrote:

For info: Downstream this caused regressions in some of our benchmarks. Not 
sure if you need to care about that (we will probably guard this with a check 
for our downstream target), but thought it might be nice to mention it.

Haven't fully investigated what happens, but I think that hoisting the COPY 
increases register pressure resulting in spill. The COPY instructions I see 
that are hoisted in that benchmark can be mapped to two categories:
```
    %228:gn32 = COPY %143:pn    ;  cross register bank copy
    %245:gn16 = COPY %227.lo:gn32   ; extracting a subreg
```
So for example hoisting the cross register bank COPY results in increasing the 
register pressure for the general gn registers in the path leading up to the 
use. Similarly, by hoisting the subreg extract the register pressure on the gn 
registers increase.

I wonder if the heuristic here perhaps should look closer at the using 
instructions to see if they actually can be hoisted as well? After all, we are 
in the path where CanCauseHighRegPressure has returned true. So traditinonally 
we have been more careful here and only hoisted trivially rematerializable MI:s.

https://github.com/llvm/llvm-project/pull/71403
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to