[llvm] [X86][NFC] Reorder the registers to reduce unnecessary iterations (PR #70222)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 23:31:48 PDT 2023


================
@@ -406,11 +406,11 @@ bool LiveVariables::HandlePhysRegKill(Register Reg, MachineInstr *MI) {
   return true;
 }
 
-void LiveVariables::HandleRegMask(const MachineOperand &MO) {
+void LiveVariables::HandleRegMask(const MachineOperand &MO, unsigned NumRegs) {
   // Call HandlePhysRegKill() for all live registers clobbered by Mask.
   // Clobbered registers are always dead, sp there is no need to use
   // HandlePhysRegDef().
-  for (unsigned Reg = 1, NumRegs = TRI->getNumRegs(); Reg != NumRegs; ++Reg) {
+  for (unsigned Reg = 1; Reg != NumRegs; ++Reg) {
----------------
arsenm wrote:

> I did an analysis on the spent time there [#67702 (comment)](https://github.com/llvm/llvm-project/pull/67702#issuecomment-1767656271).
> 
> The extra time is spent on iterations over the new registers and new register classes. LiveVariables is one of the passes with the greatest impact b/c it iterates them for each basic block. Besides, for LiveVariables and some other passes, the new registers make a bigger regmask and regset, and then operations on the regmask and regset take more time too, including allocation and loopup, etc.

FYI LiveVariables is deprecated and we should work towards getting rid of it. LiveIntervals has been the replacement for ages 

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


More information about the llvm-commits mailing list