[llvm] a4834ad - RegisterCoalescer: Shrink main range after shrinking subranges
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 06:14:26 PDT 2022
Author: Matt Arsenault
Date: 2022-07-29T08:57:28-04:00
New Revision: a4834ad06880740ee289681ea8b5844caceaa1c6
URL: https://github.com/llvm/llvm-project/commit/a4834ad06880740ee289681ea8b5844caceaa1c6
DIFF: https://github.com/llvm/llvm-project/commit/a4834ad06880740ee289681ea8b5844caceaa1c6.diff
LOG: RegisterCoalescer: Shrink main range after shrinking subranges
If the subregister uses were dead, this would leave the main range
segment pointing to a deleted instruction.
Not sure if this should try to avoid shrinking if we know we don't
have dead components.
Added:
llvm/test/CodeGen/AMDGPU/coalesce-into-dead-subreg-copies.mir
Modified:
llvm/lib/CodeGen/RegisterCoalescer.cpp
llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index 8a6f823c8a0c..4f8b6b241a76 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -2103,6 +2103,7 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
LLVM_DEBUG(dbgs() << "Shrink LaneUses (Lane " << PrintLaneMask(S.LaneMask)
<< ")\n");
LIS->shrinkToUses(S, LI.reg());
+ ShrinkMainRange = true;
}
LI.removeEmptySubRanges();
}
diff --git a/llvm/test/CodeGen/AMDGPU/coalesce-into-dead-subreg-copies.mir b/llvm/test/CodeGen/AMDGPU/coalesce-into-dead-subreg-copies.mir
new file mode 100644
index 000000000000..fba3231ecfdf
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/coalesce-into-dead-subreg-copies.mir
@@ -0,0 +1,33 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-coalescing -run-pass=simple-register-coalescing -o - %s | FileCheck %s
+
+# Check that there's no "Live segment doesn't end at a valid
+# instruction" failure after coalescing %0 into %2, which is
+# ultimately a pair of dead copies.
+
+---
+name: coalesce_into_dead_subreg_copy
+tracksRegLiveness: true
+machineFunctionInfo:
+ isEntryFunction: true
+ scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
+ stackPtrOffsetReg: '$sgpr32'
+ occupancy: 8
+body: |
+ ; CHECK-LABEL: name: coalesce_into_dead_subreg_copy
+ ; CHECK: bb.0:
+ ; CHECK-NEXT: successors: %bb.1(0x80000000)
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: dead %2:sreg_64_xexec = S_LOAD_DWORDX2_IMM undef %1:sgpr_64, 24, 0 :: (dereferenceable invariant load (s64), addrspace 4)
+ ; CHECK-NEXT: S_BRANCH %bb.1
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.1:
+ bb.0:
+ %0:sreg_64_xexec = S_LOAD_DWORDX2_IMM undef %1:sgpr_64, 24, 0 :: (dereferenceable invariant load (s64), addrspace 4)
+ undef %2.sub0:sreg_64 = COPY %0.sub0:sreg_64_xexec
+ %2.sub1:sreg_64 = COPY killed %0.sub1:sreg_64_xexec
+ S_BRANCH %bb.1
+
+ bb.1:
+
+...
diff --git a/llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll b/llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll
index 1139168f7067..19a9261f817c 100644
--- a/llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll
+++ b/llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll
@@ -10,7 +10,7 @@ define <3 x float> @liveout_undef_subrange(<3 x float> %arg) {
; CHECK: ; %bb.0: ; %bb
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; CHECK-NEXT: v_add_f32_e32 v3, v2, v2
-; CHECK-NEXT: v_add_f32_e32 v1, v1, v1
+; CHECK-NEXT: ; kill: killed $vgpr1
; CHECK-NEXT: v_add_f32_e32 v0, v0, v0
; CHECK-NEXT: .LBB0_1: ; %bb1
; CHECK-NEXT: ; =>This Loop Header: Depth=1
More information about the llvm-commits
mailing list