Repository navigation
Conversation
6d15c15 to
cda735f
Compare
|
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-llvm-regalloc Author: Yaxun (Sam) Liu (yxsamliu) ChangesMoving a dead def upward can retag a following live-range segment to the Add a shared LiveRange helper for merging adjacent same-value segments. Patch is 435.69 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/204648.diff 4 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h
index 114978996ffcf..34f318a9d2715 100644
--- a/llvm/include/llvm/CodeGen/LiveInterval.h
+++ b/llvm/include/llvm/CodeGen/LiveInterval.h
@@ -490,6 +490,13 @@ namespace llvm {
/// may have grown since it was inserted).
LLVM_ABI iterator addSegment(Segment S);
+ /// Merge the segment pointed to by @p I with its immediate neighbors when
+ /// they use the same value number and touch it. @p I must be a valid
+ /// iterator into this live range. Returns an iterator to the merged
+ /// segment, which may be @p I or the previous segment if @p I was merged
+ /// into it.
+ LLVM_ABI iterator mergeAdjacentSegments(iterator I);
+
/// Attempt to extend a value defined after @p StartIdx to include @p Use.
/// Both @p StartIdx and @p Use should be in the same basic block. In case
/// of subranges, an extension could be prevented by an explicit "undef"
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index 299db85233c2d..ed048c411316e 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/lib/CodeGen/LiveInterval.cpp
@@ -540,6 +540,28 @@ LiveRange::iterator LiveRange::addSegment(Segment S) {
return CalcLiveRangeUtilVector(this).addSegment(S);
}
+LiveRange::iterator LiveRange::mergeAdjacentSegments(iterator I) {
+ assert(segmentSet == nullptr && "Cannot merge with active segment set");
+ assert(I != end() && "Cannot merge end iterator");
+
+ if (I != begin()) {
+ iterator Prev = std::prev(I);
+ if (Prev->valno == I->valno && Prev->end == I->start) {
+ Prev->end = I->end;
+ segments.erase(I);
+ I = Prev;
+ }
+ }
+
+ iterator Next = std::next(I);
+ if (Next != end() && I->valno == Next->valno && I->end == Next->start) {
+ I->end = Next->end;
+ segments.erase(Next);
+ }
+
+ return I;
+}
+
void LiveRange::append(const Segment S) {
// Check that the segment belongs to the back of the list.
assert(segments.empty() || segments.back().end <= S.start);
@@ -754,34 +776,10 @@ VNInfo *LiveRange::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) {
iterator S = I++;
if (S->valno != V1) continue; // Not a V1 Segment.
- // Okay, we found a V1 live range. If it had a previous, touching, V2 live
- // range, extend it.
- if (S != begin()) {
- iterator Prev = S-1;
- if (Prev->valno == V2 && Prev->end == S->start) {
- Prev->end = S->end;
-
- // Erase this live-range.
- segments.erase(S);
- I = Prev+1;
- S = Prev;
- }
- }
-
- // Okay, now we have a V1 or V2 live range that is maximally merged forward.
- // Ensure that it is a V2 live-range.
+ // After changing this segment to V2, it may touch an adjacent V2 segment.
+ // Merge with either neighbor before continuing.
S->valno = V2;
-
- // If we can merge it into later V2 segments, do so now. We ignore any
- // following V1 segments, as they will be merged in subsequent iterations
- // of the loop.
- if (I != end()) {
- if (I->start == S->end && I->valno == V2) {
- S->end = I->end;
- segments.erase(I);
- I = S+1;
- }
- }
+ I = std::next(mergeAdjacentSegments(S));
}
// Now that V1 is dead, remove it.
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index 6ed379418abef..3da53566ae0c2 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -1461,9 +1461,17 @@ class LiveIntervals::HMEditor {
*(NewIdxOut + 1) = LiveRange::Segment(
NewIdxDef.getRegSlot(), (NewIdxOut + 1)->end, OldIdxVNI);
OldIdxVNI->def = NewIdxDef;
- // Modify subsequent segments to be defined by the moved def OldIdxVNI.
- for (auto *Idx = NewIdxOut + 2; Idx <= OldIdxOut; ++Idx)
+ // Retag the segments that were shifted down from [NewIdxOut + 2,
+ // OldIdxOut]. Retagging can make a segment touch another segment with
+ // the same value number, so merge as we go. Stop at the original end
+ // slot instead of using a segment count because merging may erase
+ // segments.
+ const SlotIndex RetagEnd = OldIdxOut->end;
+ for (LiveRange::iterator Idx = NewIdxOut + 2;
+ Idx != LR.end() && Idx->start < RetagEnd;) {
Idx->valno = OldIdxVNI;
+ Idx = std::next(LR.mergeAdjacentSegments(Idx));
+ }
// Aggressively remove all dead flags from the former dead definition.
// Kill/dead flags shouldn't be used while live intervals exist; they
// will be reinserted by VirtRegRewriter.
diff --git a/llvm/test/CodeGen/AMDGPU/sched-handleMoveUp-dead-def-join.mir b/llvm/test/CodeGen/AMDGPU/sched-handleMoveUp-dead-def-join.mir
new file mode 100644
index 0000000000000..6c565b3645e49
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/sched-handleMoveUp-dead-def-join.mir
@@ -0,0 +1,5263 @@
+# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx950 -verify-misched -run-pass=machine-scheduler -misched-only-block=2 -filetype=null -o /dev/null %s
+
+# This used to assert while moving a dead subregister def upward. The moved
+# def retagged a following live-range segment to the same value number as the
+# previous segment, but did not join the adjacent segments. This is a reduced
+# MIR test, but it still needs the surrounding scheduler context to reproduce
+# the problematic move.
+
+--- |
+ target datalayout = "e-m:e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n32:64-S32-A5-G1-ni:7:8:9"
+ target triple = "amdgcn-unknown-amdhsa"
+ define amdgpu_kernel void @rock_attention(ptr addrspace(1) inreg %0, ptr addrspace(1) inreg %1, ptr addrspace(1) inreg %2, ptr addrspace(1) inreg %3, ptr addrspace(1) inreg %4, ptr addrspace(1) inreg %5) #0 {
+ ret void
+ }
+ attributes #0 = { nounwind "amdgpu-cluster-dims"="1,1,1" "amdgpu-flat-work-group-size"="1,64" "uniform-work-group-size" }
+...
+---
+name: rock_attention
+alignment: 4
+tracksRegLiveness: true
+noPhis: true
+isSSA: false
+noVRegs: false
+hasFakeUses: false
+registers:
+ - { id: 0, class: sreg_32 }
+ - { id: 1, class: sreg_32 }
+ - { id: 2, class: sreg_32 }
+ - { id: 3, class: sreg_32 }
+ - { id: 4, class: vgpr_32 }
+ - { id: 5, class: vgpr_32 }
+ - { id: 6, class: vgpr_32 }
+ - { id: 7, class: vgpr_32 }
+ - { id: 8, class: vgpr_32 }
+ - { id: 9, class: vgpr_32 }
+ - { id: 10, class: sreg_32, preferred-register: '%1345' }
+ - { id: 11, class: vgpr_32 }
+ - { id: 12, class: vgpr_32 }
+ - { id: 13, class: vgpr_32 }
+ - { id: 14, class: sreg_32_xm0 }
+ - { id: 15, class: sreg_32 }
+ - { id: 16, class: sreg_64 }
+ - { id: 17, class: sreg_64 }
+ - { id: 18, class: vgpr_32 }
+ - { id: 19, class: vgpr_32 }
+ - { id: 317, class: sreg_32 }
+ - { id: 318, class: sreg_32 }
+ - { id: 319, class: sreg_32, preferred-register: '%1680' }
+ - { id: 320, class: sreg_32, preferred-register: '%815' }
+ - { id: 321, class: sgpr_32 }
+ - { id: 322, class: sgpr_32 }
+ - { id: 323, class: sgpr_32 }
+ - { id: 324, class: sgpr_32 }
+ - { id: 325, class: sgpr_32 }
+ - { id: 326, class: sgpr_32 }
+ - { id: 327, class: sgpr_32 }
+ - { id: 328, class: sgpr_32 }
+ - { id: 329, class: sgpr_32 }
+ - { id: 330, class: sgpr_32 }
+ - { id: 331, class: sgpr_32 }
+ - { id: 332, class: sgpr_32 }
+ - { id: 333, class: sgpr_32 }
+ - { id: 334, class: sgpr_32 }
+ - { id: 335, class: sgpr_32 }
+ - { id: 336, class: sgpr_32 }
+ - { id: 337, class: sgpr_32 }
+ - { id: 338, class: sgpr_32 }
+ - { id: 339, class: sgpr_32 }
+ - { id: 340, class: sgpr_32 }
+ - { id: 341, class: sgpr_32 }
+ - { id: 342, class: sgpr_32 }
+ - { id: 343, class: sgpr_32 }
+ - { id: 344, class: sgpr_32 }
+ - { id: 345, class: sgpr_32 }
+ - { id: 346, class: sgpr_32 }
+ - { id: 347, class: sgpr_32 }
+ - { id: 348, class: sgpr_32 }
+ - { id: 349, class: sgpr_32 }
+ - { id: 350, class: sgpr_32 }
+ - { id: 351, class: sgpr_32 }
+ - { id: 352, class: sgpr_32 }
+ - { id: 353, class: sgpr_32 }
+ - { id: 800, class: sreg_64 }
+ - { id: 801, class: sreg_64 }
+ - { id: 802, class: sreg_64 }
+ - { id: 803, class: sreg_64 }
+ - { id: 804, class: sreg_64 }
+ - { id: 805, class: sreg_64 }
+ - { id: 806, class: sreg_32, preferred-register: '%5180' }
+ - { id: 807, class: av_128_align2 }
+ - { id: 808, class: av_128_align2 }
+ - { id: 809, class: av_128_align2 }
+ - { id: 810, class: av_128_align2 }
+ - { id: 811, class: av_128_align2 }
+ - { id: 812, class: av_128_align2 }
+ - { id: 813, class: av_128_align2 }
+ - { id: 814, class: av_128_align2 }
+ - { id: 815, class: sreg_32, preferred-register: '%320' }
+ - { id: 816, class: sgpr_32 }
+ - { id: 817, class: sgpr_32 }
+ - { id: 818, class: sgpr_32 }
+ - { id: 819, class: sgpr_32 }
+ - { id: 820, class: sgpr_32 }
+ - { id: 821, class: sgpr_32 }
+ - { id: 822, class: sgpr_32 }
+ - { id: 823, class: sgpr_32 }
+ - { id: 824, class: sgpr_32 }
+ - { id: 825, class: sgpr_32 }
+ - { id: 826, class: sgpr_32 }
+ - { id: 827, class: sgpr_32 }
+ - { id: 828, class: sgpr_32 }
+ - { id: 829, class: sgpr_32 }
+ - { id: 830, class: sgpr_32 }
+ - { id: 831, class: sgpr_32 }
+ - { id: 832, class: sgpr_32 }
+ - { id: 833, class: sgpr_32 }
+ - { id: 834, class: sgpr_32 }
+ - { id: 835, class: sgpr_32 }
+ - { id: 836, class: sgpr_32 }
+ - { id: 1283, class: sreg_64 }
+ - { id: 1284, class: sreg_64 }
+ - { id: 1285, class: sreg_64 }
+ - { id: 1286, class: sreg_64 }
+ - { id: 1287, class: sreg_64 }
+ - { id: 1288, class: sreg_64 }
+ - { id: 1289, class: sreg_64 }
+ - { id: 1290, class: sreg_64 }
+ - { id: 1291, class: sreg_64 }
+ - { id: 1292, class: sreg_64 }
+ - { id: 1293, class: sreg_64 }
+ - { id: 1294, class: sreg_64 }
+ - { id: 1295, class: sreg_64 }
+ - { id: 1296, class: sreg_64 }
+ - { id: 1297, class: sreg_64 }
+ - { id: 1298, class: sreg_64 }
+ - { id: 1299, class: sreg_64 }
+ - { id: 1300, class: sreg_64 }
+ - { id: 1301, class: sreg_64 }
+ - { id: 1302, class: sreg_64 }
+ - { id: 1303, class: sreg_64 }
+ - { id: 1304, class: sreg_32 }
+ - { id: 1305, class: av_128_align2 }
+ - { id: 1306, class: av_128_align2 }
+ - { id: 1307, class: av_128_align2 }
+ - { id: 1308, class: av_128_align2 }
+ - { id: 1309, class: av_128_align2 }
+ - { id: 1310, class: av_128_align2 }
+ - { id: 1311, class: av_128_align2 }
+ - { id: 1312, class: av_128_align2 }
+ - { id: 1313, class: vgpr_32 }
+ - { id: 1314, class: sgpr_64 }
+ - { id: 1315, class: sgpr_64 }
+ - { id: 1316, class: sgpr_64 }
+ - { id: 1317, class: sgpr_64 }
+ - { id: 1318, class: sreg_64 }
+ - { id: 1319, class: sreg_64 }
+ - { id: 1320, class: sreg_64 }
+ - { id: 1321, class: sreg_64_xexec_xnull }
+ - { id: 1322, class: sgpr_32 }
+ - { id: 1323, class: sgpr_32 }
+ - { id: 12372, class: vgpr_32 }
+ - { id: 12373, class: vgpr_32 }
+ - { id: 12374, class: vgpr_32 }
+ - { id: 12375, class: vgpr_32 }
+ - { id: 12376, class: vgpr_32 }
+liveins:
+ - { reg: '$vgpr0', virtual-reg: '%1313' }
+ - { reg: '$sgpr4_sgpr5', virtual-reg: '%1316' }
+ - { reg: '$sgpr8_sgpr9', virtual-reg: '%1318' }
+ - { reg: '$sgpr10_sgpr11', virtual-reg: '%1319' }
+ - { reg: '$sgpr12_sgpr13', virtual-reg: '%1320' }
+ - { reg: '$sgpr14_sgpr15', virtual-reg: '%1321' }
+ - { reg: '$sgpr16', virtual-reg: '%1322' }
+frameInfo:
+ maxAlignment: 1
+machineFunctionInfo:
+ explicitKernArgSize: 48
+ maxKernArgAlign: 8
+ ldsSize: 51552
+ isEntryFunction: true
+ numWaveDispatchSGPRs: 16
+ stackPtrOffsetReg: '$sgpr32'
+ argumentInfo:
+ dispatchPtr: { reg: '$sgpr0_sgpr1' }
+ queuePtr: { reg: '$sgpr2_sgpr3' }
+ kernargSegmentPtr: { reg: '$sgpr4_sgpr5' }
+ dispatchID: { reg: '$sgpr6_sgpr7' }
+ firstKernArgPreloadReg: { reg: '$sgpr8' }
+ workGroupIDX: { reg: '$sgpr16' }
+ workGroupIDY: { reg: '$sgpr17' }
+ workGroupIDZ: { reg: '$sgpr18' }
+ workItemIDX: { reg: '$vgpr0', mask: 1023 }
+ workItemIDY: { reg: '$vgpr0', mask: 1047552 }
+ workItemIDZ: { reg: '$vgpr0', mask: 1072693248 }
+ occupancy: 1
+ sgprForEXECCopy: '$sgpr100_sgpr101'
+ numKernargPreloadSGPRs: 8
+body: |
+ bb.0:
+ liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr12_sgpr13, $sgpr14_sgpr15, $sgpr16
+
+ %1322:sgpr_32 = COPY $sgpr16
+ %1321:sreg_64_xexec_xnull = COPY $sgpr14_sgpr15
+ undef %5187.sub0_sub1:sgpr_128 = COPY $sgpr12_sgpr13
+ undef %1694.sub0_sub1:sgpr_128 = COPY $sgpr10_sgpr11
+ undef %1367.sub0_sub1:sgpr_128 = COPY $sgpr8_sgpr9
+ %1316:sgpr_64(p4) = COPY $sgpr4_sgpr5
+ %1313:vgpr_32(s32) = COPY $vgpr0
+ %11814:sgpr_128 = S_LOAD_DWORDX4_IMM %1316(p4), 32, 0
+ %1337:vgpr_32 = AV_MOV_B32_IMM_PSEUDO 0, implicit $exec
+ %12086:sreg_32 = S_MOV_B32 45408
+ %12080:sreg_32 = S_MOV_B32 32768
+ %12085:sreg_32 = S_MOV_B32 47456
+ %12079:sreg_32 = S_MOV_B32 36992
+ %1339:sreg_32 = S_LSHR_B32 %1322, 2, implicit-def dead $scc
+ %12087:sreg_32 = S_MOV_B32 1
+ %1340:sreg_32 = S_LSHL_B32 %1322, 1, implicit-def dead $scc
+ %1342:sreg_32 = S_AND_B32 %1340, 6, implicit-def dead $scc
+ %1343:sreg_32 = nuw nsw S_ADD_I32 %1342, %1339, implicit-def dead $scc
+ S_CMP_GT_I32 %1322, 7, implicit-def $scc
+ %1345:sreg_32 = S_CSELECT_B32 %1322, %1343, implicit killed $scc
+ %1347:vgpr_32 = V_AND_B32_e32 1023, %1313(s32), implicit $exec
+ %1349:vgpr_32 = V_AND_B32_e32 15, %1313(s32), implicit $exec
+ %1351:vgpr_32 = V_AND_B32_e32 32, %1313(s32), implicit $exec
+ %1352:vgpr_32 = V_AND_B32_e32 1, %1313(s32), implicit $exec
+ %1354:vgpr_32 = V_AND_B32_e32 48, %1313(s32), implicit $exec
+ %1355:sreg_64_xexec = V_CMP_GT_U32_e64 7, %1347, implicit $exec
+ %10:sreg_32 = S_MUL_I32 %1345, 112
+ %1358:vgpr_32 = nuw nsw V_LSHLREV_B32_e32 4, %1347, implicit $exec
+ %1360:vgpr_32 = disjoint V_OR_B32_e32 1024, %1358, implicit $exec
+ %1361:vgpr_32 = V_ADD_U32_e32 %10, %1358, implicit $exec
+ %1367.sub1:sgpr_128 = S_AND_B32 %1367.sub1, 65535, implicit-def dead $scc
+ %1367.sub3:sgpr_128 = S_MOV_B32 159744
+ %1367.sub2:sgpr_128 = S_MOV_B32 2147483646
+ %1368:vgpr_32 = V_MOV_B32_e32 -2147483648, implicit $exec
+ %1369:vgpr_32 = V_CNDMASK_B32_e64 0, %1368, 0, %1361, %1355, implicit $exec
+ %12088:sreg_32 = S_MOV_B32 0
+ %1370:av_128_align2 = BUFFER_LOAD_DWORDX4_OFFEN %1369, %1367, 0, 0, 0, 0, implicit $exec
+ %1371:av_128_align2 = BUFFER_LOAD_DWORDX4_OFFEN %1368, %1367, 0, 0, 0, 0, implicit $exec
+ DS_WRITE_B128_gfx9 %1358, %1370, 0, 0, implicit $exec
+ DS_WRITE_B128_gfx9 %1358, %1371, 1024, 0, implicit $exec
+ S_WAITCNT 49279
+ WAVE_BARRIER
+ %1372:vgpr_32 = nuw nsw V_LSHLREV_B32_e32 1, %1351, implicit $exec
+ %1373:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 0, 0, implicit $exec
+ %1374:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 16, 0, implicit $exec
+ %1375:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 32, 0, implicit $exec
+ %1376:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 48, 0, implicit $exec
+ %1377:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 128, 0, implicit $exec
+ %1378:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 144, 0, implicit $exec
+ %1379:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 160, 0, implicit $exec
+ %1380:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 176, 0, implicit $exec
+ %1381:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 256, 0, implicit $exec
+ %1382:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 272, 0, implicit $exec
+ %1383:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 288, 0, implicit $exec
+ %1384:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 304, 0, implicit $exec
+ %1385:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 384, 0, implicit $exec
+ %1386:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 400, 0, implicit $exec
+ %1387:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 416, 0, implicit $exec
+ %1388:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 432, 0, implicit $exec
+ %1389:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 512, 0, implicit $exec
+ %1390:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 528, 0, implicit $exec
+ %1391:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 544, 0, implicit $exec
+ %1392:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 560, 0, implicit $exec
+ %1393:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 640, 0, implicit $exec
+ %1394:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 656, 0, implicit $exec
+ %1395:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 672, 0, implicit $exec
+ %1396:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 688, 0, implicit $exec
+ %1397:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 768, 0, implicit $exec
+ %1398:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 784, 0, implicit $exec
+ %1399:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 800, 0, implicit $exec
+ %1400:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 816, 0, implicit $exec
+ %1401:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 896, 0, implicit $exec
+ %1402:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 912, 0, implicit $exec
+ %1403:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 928, 0, implicit $exec
+ %1404:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 944, 0, implicit $exec
+ %1405:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1024, 0, implicit $exec
+ %1406:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1040, 0, implicit $exec
+ %1407:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1056, 0, implicit $exec
+ %1408:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1072, 0, implicit $exec
+ %1409:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1152, 0, implicit $exec
+ %1410:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1168, 0, implicit $exec
+ %1411:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1184, 0, implicit $exec
+ %1412:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1200, 0, implicit $exec
+ %1413:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1280, 0, implicit $exec
+ %1414:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1296, 0, implicit $exec
+ %1415:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1312, 0, implicit $exec
+ %1416:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1328, 0, implicit $exec
+ %1417:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1408, 0, implicit $exec
+ %1418:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1424, 0, implicit $exec
+ %1419:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1440, 0, implicit $exec
+ %1420:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1456, 0, implicit $exec
+ %1421:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1536, 0, implicit $exec
+ %1422:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1552, 0, implicit $exec
+ %1423:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1568, 0, implicit $exec
+ %1424:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1584, 0, implicit $exec
+ %1425:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1664, 0, implicit $exec
+ %1426:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1680, 0, implicit $exec
+ %1427:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1696, 0, implicit $exec
+ %1428:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1712, 0, implicit $exec
+ %1429:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1792, 0, implicit $exec
+ %1430:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1808, 0, implicit $exec
+ %1431:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1824, 0, implicit $exec
+ %1432:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1840, 0, implicit $exec
+ %1433:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1920, 0, implicit $exec
+ %1434:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1936, 0, implicit $exec
+ %1435:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1952, 0, implicit $exec
+ %1436:vreg_128_align2 = DS_READ_B128_gfx9 %1372, 1968, 0, implicit $exec
+ %1437:vgpr_32 = GLOBAL_LOAD_UBYTE_SADDR %1321, %1337, 0, 0, implicit $exec
+ %12083:sreg_32_xm0 = V_READFIRSTLANE_B32 %1437, implicit $exec
+ %12081:vgpr_32 = GLOBAL_LOAD_USHORT_SADDR %11814.sub0_sub1, %1337, 0, 0, implicit $exec
+ %1440:sreg_32 = S_LSHL_B32 %1345, 16, implicit-def dead $scc
+ %1441:vgpr_32 = disjoint V_OR_B32_e32 %1440, %1358, implicit $exec
+ %1442:vgpr_32 = disjoint V_OR_B32_e32 %1440, %1360, implicit $exec
+ %1694.sub1:sgpr_128 =...
[truncated]
|
Moving a dead def upward can retag a following live-range segment to the same value as the previous segment. That leaves adjacent same-value segments, which live range verification rejects. Add a shared LiveRange helper for merging adjacent same-value segments. Use it in the existing value-number merge code and after retagging later segments for a moved dead def. Add an AMDGPU scheduler regression test.
cda735f to
d0f1670
Compare
vpykhtin
left a comment
There was a problem hiding this comment.
Seems that unit test reproducer is hard to create (Claude failed), so LGTM.
Moving a dead def upward can retag a following live-range segment to the
same value as the previous segment. That leaves adjacent same-value
segments, which live range verification rejects.
Add a shared LiveRange helper for merging adjacent same-value segments.
Use it in the existing value-number merge code and after retagging later
segments for a moved dead def. Add an AMDGPU scheduler regression test.