Skip to content

Commit ab52103

Browse files
committed
Greedy: Take hints from copy to physical subreg
Previously this took hints from subregister extract of physreg, like %vreg.sub = COPY $physreg This now also handles the rarer case: $physreg_sub = COPY %vreg Also make an accidental bug here before explicit; this was only using the superregister as a hint if it was already in the copy, and not if using the existing assignment. There are a handful of regressions in that case, so leave that extension for a future change.
1 parent 5f93f5c commit ab52103

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

llvm/lib/CodeGen/RegAllocGreedy.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,25 +2439,28 @@ void RAGreedy::collectHintInfo(Register Reg, HintsInfo &Out) {
24392439
unsigned SubReg = Opnd.getSubReg();
24402440

24412441
// Get the current assignment.
2442-
MCRegister OtherPhysReg =
2443-
OtherReg.isPhysical() ? OtherReg.asMCReg() : VRM->getPhys(OtherReg);
2444-
if (OtherSubReg) {
2445-
if (OtherReg.isPhysical()) {
2446-
MCRegister Tuple =
2447-
TRI->getMatchingSuperReg(OtherPhysReg, OtherSubReg, RC);
2448-
if (!Tuple)
2449-
continue;
2450-
OtherPhysReg = Tuple;
2451-
} else {
2452-
// TODO: There should be a hinting mechanism for subregisters
2453-
if (SubReg != OtherSubReg)
2454-
continue;
2455-
}
2442+
MCRegister OtherPhysReg;
2443+
if (OtherReg.isPhysical()) {
2444+
if (OtherSubReg)
2445+
OtherPhysReg = TRI->getMatchingSuperReg(OtherReg, OtherSubReg, RC);
2446+
else if (SubReg)
2447+
OtherPhysReg = TRI->getMatchingSuperReg(OtherReg, SubReg, RC);
2448+
else
2449+
OtherPhysReg = OtherReg;
2450+
} else {
2451+
OtherPhysReg = VRM->getPhys(OtherReg);
2452+
// TODO: Should find matching superregister, but applying this in the
2453+
// non-hint case currently causes regressions
2454+
2455+
if (SubReg && OtherSubReg && SubReg != OtherSubReg)
2456+
continue;
24562457
}
24572458

24582459
// Push the collected information.
2459-
Out.push_back(HintInfo(MBFI->getBlockFreq(Instr.getParent()), OtherReg,
2460-
OtherPhysReg));
2460+
if (OtherPhysReg) {
2461+
Out.push_back(HintInfo(MBFI->getBlockFreq(Instr.getParent()), OtherReg,
2462+
OtherPhysReg));
2463+
}
24612464
}
24622465
}
24632466

llvm/test/CodeGen/X86/shift-i128.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ define void @test_shl_v2i128(<2 x i128> %x, <2 x i128> %a, ptr nocapture %r) nou
613613
; i686-NEXT: shldl %cl, %esi, %ebx
614614
; i686-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
615615
; i686-NEXT: movl %edi, %esi
616-
; i686-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
617-
; i686-NEXT: movl %eax, %ecx
616+
; i686-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
618617
; i686-NEXT: shll %cl, %esi
619618
; i686-NEXT: shldl %cl, %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Spill
620619
; i686-NEXT: negl %edx

0 commit comments

Comments
 (0)