|
10 | 10 | // register in the singleton vmv0 register class instead of copying them to $v0 |
11 | 11 | // straight away, to make optimizing masks easier. |
12 | 12 | // |
13 | | -// However the register allocator struggles with singleton register classes and |
14 | | -// will run into errors like "ran out of registers during register allocation in |
15 | | -// function" |
| 13 | +// However register coalescing may end up coleascing copies into vmv0, resulting |
| 14 | +// in instructions with multiple uses of vmv0 that the register allocator can't |
| 15 | +// allocate: |
16 | 16 | // |
17 | | -// This pass runs just before register allocation and replaces any uses* of vmv0 |
18 | | -// with copies to $v0. |
| 17 | +// %x:vrnov0 = PseudoVADD_VV_M1_MASK %0:vrnov0, %1:vr, %2:vmv0, %3:vmv0, ... |
| 18 | +// |
| 19 | +// To avoid this, this pass replaces any uses* of vmv0 with copies to $v0 before |
| 20 | +// register coalescing and allocation: |
19 | 21 | // |
20 | 22 | // %x:vrnov0 = PseudoVADD_VV_M1_MASK %0:vrnov0, %1:vr, %2:vr, %3:vmv0, ... |
21 | 23 | // -> |
@@ -128,8 +130,8 @@ bool RISCVVMV0Elimination::runOnMachineFunction(MachineFunction &MF) { |
128 | 130 | Src.isVirtual() && "vmv0 use in unexpected form"); |
129 | 131 |
|
130 | 132 | // Peek through a single copy to match what isel does. |
131 | | - MachineInstr *SrcMI = MRI.getVRegDef(Src); |
132 | | - if (SrcMI->isCopy() && SrcMI->getOperand(1).getReg().isVirtual()) { |
| 133 | + if (MachineInstr *SrcMI = MRI.getVRegDef(Src); |
| 134 | + SrcMI->isCopy() && SrcMI->getOperand(1).getReg().isVirtual()) { |
133 | 135 | assert(SrcMI->getOperand(1).getSubReg() == RISCV::NoSubRegister); |
134 | 136 | Src = SrcMI->getOperand(1).getReg(); |
135 | 137 | } |
@@ -161,11 +163,10 @@ bool RISCVVMV0Elimination::runOnMachineFunction(MachineFunction &MF) { |
161 | 163 | MI.isInlineAsm() || |
162 | 164 | MRI.getVRegDef(MO.getReg())->isInlineAsm() && |
163 | 165 | "Non-inline-asm use of vmv0 left behind"); |
164 | | - MadeChange = true; |
165 | 166 | } |
166 | 167 | } |
167 | 168 | } |
168 | 169 | } |
169 | 170 |
|
170 | | - return MadeChange; |
| 171 | + return true; |
171 | 172 | } |
0 commit comments