Skip to content

Commit 3537e8a

Browse files
authored
RegAllocGreedy: Check if copied lanes are live in trySplitAroundHintReg (#160424)
For subregister copies, do a subregister live check instead of checking the main range. Doesn't do much yet, the split analysis still does not track live ranges.
1 parent 8dd2846 commit 3537e8a

File tree

4 files changed

+105
-90
lines changed

4 files changed

+105
-90
lines changed

llvm/lib/CodeGen/RegAllocGreedy.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,8 +1406,24 @@ bool RAGreedy::trySplitAroundHintReg(MCPhysReg Hint,
14061406
continue;
14071407

14081408
// Check if VirtReg interferes with OtherReg after this COPY instruction.
1409-
if (!IsDef && VirtReg.liveAt(LIS->getInstructionIndex(Instr).getRegSlot()))
1410-
continue;
1409+
if (Opnd.readsReg()) {
1410+
SlotIndex Index = LIS->getInstructionIndex(Instr).getRegSlot();
1411+
1412+
if (SubReg) {
1413+
LaneBitmask Mask = TRI->getSubRegIndexLaneMask(SubReg);
1414+
if (IsDef)
1415+
Mask = ~Mask;
1416+
1417+
if (any_of(VirtReg.subranges(), [=](const LiveInterval::SubRange &S) {
1418+
return (S.LaneMask & Mask).any() && S.liveAt(Index);
1419+
})) {
1420+
continue;
1421+
}
1422+
} else {
1423+
if (VirtReg.liveAt(Index))
1424+
continue;
1425+
}
1426+
}
14111427

14121428
MCRegister OtherPhysReg =
14131429
OtherReg.isPhysical() ? OtherReg.asMCReg() : VRM->getPhys(OtherReg);

llvm/test/CodeGen/SystemZ/fp-cmp-04.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ define half @f12_half(half %dummy, half %val, ptr %dest) {
235235
; CHECK-NEXT: blah %f0
236236
; CHECK-NEXT: #NO_APP
237237
; CHECK-NEXT: brasl %r14, __extendhfsf2@PLT
238-
; CHECK-NEXT: ltebr %f0, %f0
238+
; CHECK-NEXT: ltebr %f1, %f0
239239
; CHECK-NEXT: jl .LBB11_2
240240
; CHECK-NEXT:# %bb.1:
241241
; CHECK-NEXT: lgdr %r0, %f8
@@ -344,7 +344,7 @@ define half @f15_half(half %val, half %dummy, ptr %dest) {
344344
; CHECK-NEXT: blah %f2
345345
; CHECK-NEXT: #NO_APP
346346
; CHECK-NEXT: brasl %r14, __extendhfsf2@PLT
347-
; CHECK-NEXT: ltebr %f0, %f0
347+
; CHECK-NEXT: ltebr %f1, %f0
348348
; CHECK-NEXT: jl .LBB15_2
349349
; CHECK-NEXT:# %bb.1:
350350
; CHECK-NEXT: lgdr %r0, %f8

llvm/test/CodeGen/X86/fshl.ll

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -335,84 +335,83 @@ define i128 @var_shift_i128(i128 %x, i128 %y, i128 %z) nounwind {
335335
; X86-SLOW-NEXT: pushl %esi
336336
; X86-SLOW-NEXT: andl $-16, %esp
337337
; X86-SLOW-NEXT: subl $32, %esp
338-
; X86-SLOW-NEXT: movl 24(%ebp), %esi
338+
; X86-SLOW-NEXT: movl 24(%ebp), %edi
339339
; X86-SLOW-NEXT: movl 28(%ebp), %eax
340340
; X86-SLOW-NEXT: movl 48(%ebp), %edx
341341
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
342342
; X86-SLOW-NEXT: testb $64, %cl
343-
; X86-SLOW-NEXT: movl 52(%ebp), %edi
343+
; X86-SLOW-NEXT: movl 52(%ebp), %ebx
344344
; X86-SLOW-NEXT: jne .LBB6_1
345345
; X86-SLOW-NEXT: # %bb.2:
346346
; X86-SLOW-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
347-
; X86-SLOW-NEXT: movl %esi, %edx
348-
; X86-SLOW-NEXT: movl 32(%ebp), %esi
349-
; X86-SLOW-NEXT: movl %edi, %ecx
350-
; X86-SLOW-NEXT: movl %eax, %edi
347+
; X86-SLOW-NEXT: movl %edi, %edx
348+
; X86-SLOW-NEXT: movl 32(%ebp), %edi
349+
; X86-SLOW-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
350+
; X86-SLOW-NEXT: movl %eax, %ebx
351351
; X86-SLOW-NEXT: movl 36(%ebp), %eax
352352
; X86-SLOW-NEXT: jmp .LBB6_3
353353
; X86-SLOW-NEXT: .LBB6_1:
354354
; X86-SLOW-NEXT: movl 40(%ebp), %ecx
355355
; X86-SLOW-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
356356
; X86-SLOW-NEXT: movl 44(%ebp), %ecx
357+
; X86-SLOW-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
357358
; X86-SLOW-NEXT: .LBB6_3:
358-
; X86-SLOW-NEXT: movl 56(%ebp), %ebx
359-
; X86-SLOW-NEXT: testb $32, %bl
359+
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
360+
; X86-SLOW-NEXT: testb $32, %cl
360361
; X86-SLOW-NEXT: jne .LBB6_4
361362
; X86-SLOW-NEXT: # %bb.5:
362-
; X86-SLOW-NEXT: movl %ecx, %ebx
363363
; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
364-
; X86-SLOW-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
364+
; X86-SLOW-NEXT: movl %edx, %edi
365+
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
365366
; X86-SLOW-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
366367
; X86-SLOW-NEXT: jmp .LBB6_6
367368
; X86-SLOW-NEXT: .LBB6_4:
368-
; X86-SLOW-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
369369
; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
370-
; X86-SLOW-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
371-
; X86-SLOW-NEXT: movl %ecx, %edx
372-
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
370+
; X86-SLOW-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
371+
; X86-SLOW-NEXT: movl %edx, %ebx
372+
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
373+
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
373374
; X86-SLOW-NEXT: .LBB6_6:
374-
; X86-SLOW-NEXT: movl %edx, %esi
375+
; X86-SLOW-NEXT: movl %edi, %eax
376+
; X86-SLOW-NEXT: shll %cl, %eax
377+
; X86-SLOW-NEXT: shrl %esi
378+
; X86-SLOW-NEXT: movl %ecx, %edx
379+
; X86-SLOW-NEXT: notb %dl
380+
; X86-SLOW-NEXT: movl %edx, %ecx
381+
; X86-SLOW-NEXT: shrl %cl, %esi
382+
; X86-SLOW-NEXT: orl %eax, %esi
383+
; X86-SLOW-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
384+
; X86-SLOW-NEXT: movl %ebx, %eax
375385
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
376-
; X86-SLOW-NEXT: shll %cl, %esi
377-
; X86-SLOW-NEXT: movl %ebx, %edi
386+
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
387+
; X86-SLOW-NEXT: shll %cl, %eax
378388
; X86-SLOW-NEXT: shrl %edi
379-
; X86-SLOW-NEXT: movl %ecx, %ebx
380-
; X86-SLOW-NEXT: notb %bl
381-
; X86-SLOW-NEXT: movl %ebx, %ecx
382-
; X86-SLOW-NEXT: movb %bl, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
389+
; X86-SLOW-NEXT: movl %edx, %ecx
383390
; X86-SLOW-NEXT: shrl %cl, %edi
384-
; X86-SLOW-NEXT: orl %esi, %edi
391+
; X86-SLOW-NEXT: orl %eax, %edi
385392
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
386393
; X86-SLOW-NEXT: movl %esi, %eax
387394
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
388395
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
389396
; X86-SLOW-NEXT: shll %cl, %eax
390-
; X86-SLOW-NEXT: shrl %edx
391-
; X86-SLOW-NEXT: movl %ebx, %ecx
392-
; X86-SLOW-NEXT: shrl %cl, %edx
393-
; X86-SLOW-NEXT: orl %eax, %edx
394-
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
395-
; X86-SLOW-NEXT: movl %ebx, %eax
397+
; X86-SLOW-NEXT: shrl %ebx
398+
; X86-SLOW-NEXT: movl %edx, %ecx
399+
; X86-SLOW-NEXT: shrl %cl, %ebx
400+
; X86-SLOW-NEXT: orl %eax, %ebx
396401
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
397402
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
403+
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
398404
; X86-SLOW-NEXT: shll %cl, %eax
399405
; X86-SLOW-NEXT: shrl %esi
400-
; X86-SLOW-NEXT: movzbl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 1-byte Folded Reload
406+
; X86-SLOW-NEXT: movl %edx, %ecx
401407
; X86-SLOW-NEXT: shrl %cl, %esi
402408
; X86-SLOW-NEXT: orl %eax, %esi
403-
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
404-
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
405-
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
406-
; X86-SLOW-NEXT: shll %cl, %eax
407-
; X86-SLOW-NEXT: shrl %ebx
408-
; X86-SLOW-NEXT: movzbl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 1-byte Folded Reload
409-
; X86-SLOW-NEXT: shrl %cl, %ebx
410-
; X86-SLOW-NEXT: orl %eax, %ebx
411409
; X86-SLOW-NEXT: movl 8(%ebp), %eax
412-
; X86-SLOW-NEXT: movl %ebx, 12(%eax)
413-
; X86-SLOW-NEXT: movl %esi, 8(%eax)
414-
; X86-SLOW-NEXT: movl %edx, 4(%eax)
415-
; X86-SLOW-NEXT: movl %edi, (%eax)
410+
; X86-SLOW-NEXT: movl %esi, 12(%eax)
411+
; X86-SLOW-NEXT: movl %ebx, 8(%eax)
412+
; X86-SLOW-NEXT: movl %edi, 4(%eax)
413+
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
414+
; X86-SLOW-NEXT: movl %ecx, (%eax)
416415
; X86-SLOW-NEXT: leal -12(%ebp), %esp
417416
; X86-SLOW-NEXT: popl %esi
418417
; X86-SLOW-NEXT: popl %edi

llvm/test/CodeGen/X86/fshr.ll

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -322,79 +322,79 @@ define i128 @var_shift_i128(i128 %x, i128 %y, i128 %z) nounwind {
322322
; X86-SLOW-NEXT: subl $16, %esp
323323
; X86-SLOW-NEXT: movl 24(%ebp), %edx
324324
; X86-SLOW-NEXT: movl 28(%ebp), %esi
325-
; X86-SLOW-NEXT: movl 48(%ebp), %ebx
325+
; X86-SLOW-NEXT: movl 48(%ebp), %edi
326326
; X86-SLOW-NEXT: movl 56(%ebp), %eax
327327
; X86-SLOW-NEXT: testb $64, %al
328-
; X86-SLOW-NEXT: movl 52(%ebp), %edi
328+
; X86-SLOW-NEXT: movl 52(%ebp), %eax
329329
; X86-SLOW-NEXT: je .LBB6_1
330330
; X86-SLOW-NEXT: # %bb.2:
331-
; X86-SLOW-NEXT: movl %ebx, (%esp) # 4-byte Spill
332-
; X86-SLOW-NEXT: movl %edx, %ebx
331+
; X86-SLOW-NEXT: movl %edi, (%esp) # 4-byte Spill
332+
; X86-SLOW-NEXT: movl %edx, %edi
333333
; X86-SLOW-NEXT: movl 32(%ebp), %edx
334-
; X86-SLOW-NEXT: movl %edi, %eax
335-
; X86-SLOW-NEXT: movl %esi, %edi
334+
; X86-SLOW-NEXT: movl %eax, %ecx
335+
; X86-SLOW-NEXT: movl %esi, %eax
336336
; X86-SLOW-NEXT: movl 36(%ebp), %esi
337337
; X86-SLOW-NEXT: jmp .LBB6_3
338338
; X86-SLOW-NEXT: .LBB6_1:
339-
; X86-SLOW-NEXT: movl 40(%ebp), %eax
340-
; X86-SLOW-NEXT: movl %eax, (%esp) # 4-byte Spill
341-
; X86-SLOW-NEXT: movl 44(%ebp), %eax
339+
; X86-SLOW-NEXT: movl 40(%ebp), %ecx
340+
; X86-SLOW-NEXT: movl %ecx, (%esp) # 4-byte Spill
341+
; X86-SLOW-NEXT: movl 44(%ebp), %ecx
342342
; X86-SLOW-NEXT: .LBB6_3:
343-
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
344-
; X86-SLOW-NEXT: testb $32, %cl
343+
; X86-SLOW-NEXT: movl 56(%ebp), %ebx
344+
; X86-SLOW-NEXT: testb $32, %bl
345345
; X86-SLOW-NEXT: je .LBB6_4
346346
; X86-SLOW-NEXT: # %bb.5:
347-
; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
347+
; X86-SLOW-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
348348
; X86-SLOW-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
349+
; X86-SLOW-NEXT: movl %ecx, %ebx
349350
; X86-SLOW-NEXT: jmp .LBB6_6
350351
; X86-SLOW-NEXT: .LBB6_4:
351352
; X86-SLOW-NEXT: movl %edx, %esi
353+
; X86-SLOW-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
352354
; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
353-
; X86-SLOW-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
354-
; X86-SLOW-NEXT: movl %eax, %ebx
355-
; X86-SLOW-NEXT: movl (%esp), %eax # 4-byte Reload
355+
; X86-SLOW-NEXT: movl %ecx, %edi
356+
; X86-SLOW-NEXT: movl (%esp), %ebx # 4-byte Reload
356357
; X86-SLOW-NEXT: .LBB6_6:
357-
; X86-SLOW-NEXT: shrl %cl, %eax
358-
; X86-SLOW-NEXT: movl %eax, %edx
359-
; X86-SLOW-NEXT: movl %ecx, %eax
360-
; X86-SLOW-NEXT: notb %al
361-
; X86-SLOW-NEXT: movl %ebx, %edi
362-
; X86-SLOW-NEXT: addl %ebx, %ebx
363-
; X86-SLOW-NEXT: movl %eax, %ecx
364-
; X86-SLOW-NEXT: shll %cl, %ebx
365-
; X86-SLOW-NEXT: orl %edx, %ebx
366-
; X86-SLOW-NEXT: movl %ebx, (%esp) # 4-byte Spill
367358
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
368-
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
369-
; X86-SLOW-NEXT: shrl %cl, %edi
370-
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
371-
; X86-SLOW-NEXT: leal (%ebx,%ebx), %edx
372-
; X86-SLOW-NEXT: movl %eax, %ecx
373-
; X86-SLOW-NEXT: shll %cl, %edx
374-
; X86-SLOW-NEXT: orl %edi, %edx
359+
; X86-SLOW-NEXT: shrl %cl, %ebx
360+
; X86-SLOW-NEXT: movl %ecx, %edx
361+
; X86-SLOW-NEXT: notb %dl
362+
; X86-SLOW-NEXT: movl %edi, %eax
363+
; X86-SLOW-NEXT: addl %edi, %edi
364+
; X86-SLOW-NEXT: movl %edx, %ecx
365+
; X86-SLOW-NEXT: shll %cl, %edi
366+
; X86-SLOW-NEXT: orl %ebx, %edi
367+
; X86-SLOW-NEXT: movl %edi, (%esp) # 4-byte Spill
375368
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
376369
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
377-
; X86-SLOW-NEXT: shrl %cl, %ebx
378-
; X86-SLOW-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
370+
; X86-SLOW-NEXT: shrl %cl, %eax
379371
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
380372
; X86-SLOW-NEXT: leal (%edi,%edi), %ebx
381-
; X86-SLOW-NEXT: movl %eax, %ecx
373+
; X86-SLOW-NEXT: movl %edx, %ecx
382374
; X86-SLOW-NEXT: shll %cl, %ebx
383-
; X86-SLOW-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Folded Reload
375+
; X86-SLOW-NEXT: orl %eax, %ebx
384376
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
385377
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
386378
; X86-SLOW-NEXT: shrl %cl, %edi
379+
; X86-SLOW-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
380+
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
381+
; X86-SLOW-NEXT: leal (%eax,%eax), %edi
382+
; X86-SLOW-NEXT: movl %edx, %ecx
383+
; X86-SLOW-NEXT: shll %cl, %edi
384+
; X86-SLOW-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Folded Reload
385+
; X86-SLOW-NEXT: movl 56(%ebp), %ecx
386+
; X86-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
387+
; X86-SLOW-NEXT: shrl %cl, %eax
387388
; X86-SLOW-NEXT: addl %esi, %esi
388-
; X86-SLOW-NEXT: movl %eax, %ecx
389+
; X86-SLOW-NEXT: movl %edx, %ecx
389390
; X86-SLOW-NEXT: shll %cl, %esi
390-
; X86-SLOW-NEXT: orl %edi, %esi
391-
; X86-SLOW-NEXT: movl 8(%ebp), %ecx
392-
; X86-SLOW-NEXT: movl %esi, 12(%ecx)
393-
; X86-SLOW-NEXT: movl %ebx, 8(%ecx)
394-
; X86-SLOW-NEXT: movl %edx, 4(%ecx)
395-
; X86-SLOW-NEXT: movl (%esp), %eax # 4-byte Reload
396-
; X86-SLOW-NEXT: movl %eax, (%ecx)
397-
; X86-SLOW-NEXT: movl %ecx, %eax
391+
; X86-SLOW-NEXT: orl %eax, %esi
392+
; X86-SLOW-NEXT: movl 8(%ebp), %eax
393+
; X86-SLOW-NEXT: movl %esi, 12(%eax)
394+
; X86-SLOW-NEXT: movl %edi, 8(%eax)
395+
; X86-SLOW-NEXT: movl %ebx, 4(%eax)
396+
; X86-SLOW-NEXT: movl (%esp), %ecx # 4-byte Reload
397+
; X86-SLOW-NEXT: movl %ecx, (%eax)
398398
; X86-SLOW-NEXT: leal -12(%ebp), %esp
399399
; X86-SLOW-NEXT: popl %esi
400400
; X86-SLOW-NEXT: popl %edi

0 commit comments

Comments
 (0)