Skip to content

Commit 5f2437a

Browse files
arsenmmahesh-attarde
authored andcommitted
Greedy: Take hints from copy to physical subreg (llvm#160467)
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 3f477e8 commit 5f2437a

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
@@ -2435,25 +2435,28 @@ void RAGreedy::collectHintInfo(Register Reg, HintsInfo &Out) {
24352435
unsigned SubReg = Opnd.getSubReg();
24362436

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

24542455
// Push the collected information.
2455-
Out.push_back(HintInfo(MBFI->getBlockFreq(Instr.getParent()), OtherReg,
2456-
OtherPhysReg));
2456+
if (OtherPhysReg) {
2457+
Out.push_back(HintInfo(MBFI->getBlockFreq(Instr.getParent()), OtherReg,
2458+
OtherPhysReg));
2459+
}
24572460
}
24582461
}
24592462

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)