Skip to content

Commit 3488632

Browse files
committed
[InterleavedAccessPass]: Ensure that dead nodes get erased only once
1 parent 7532958 commit 3488632

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

llvm/lib/CodeGen/InterleavedAccessPass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ bool InterleavedAccessImpl::runOnFunction(Function &F) {
545545
}
546546

547547
for (auto *I : DeadInsts)
548-
I->eraseFromParent();
548+
if (I->getParent())
549+
I->eraseFromParent();
549550

550551
return Changed;
551552
}

llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleave4.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,17 @@ define void @mix_interleave4_interleave2(ptr %dst1, ptr %dst2, <vscale x 4 x i32
5555
store <vscale x 8 x i32> %interleaved, ptr %dst2, align 4
5656
ret void
5757
}
58+
59+
; This case tests when the interleave is using same parameter twice,
60+
; the dead parameter will not get deleted twice.
61+
define void @duplicate_by_interleave(<vscale x 4 x i32> %A, <vscale x 4 x i32> %B, ptr writeonly %AB_duplicate) {
62+
; CHECK-LABEL: define void @duplicate_by_interleave
63+
; CHECK-SAME: (<vscale x 4 x i32> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], ptr writeonly [[AB_DUPLICATE:%.*]]) #[[ATTR0]] {
64+
; CHECK-NEXT: call void @llvm.aarch64.sve.st4.nxv4i32(<vscale x 4 x i32> [[A]], <vscale x 4 x i32> [[A]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[B]], <vscale x 4 x i1> splat (i1 true), ptr [[AB_DUPLICATE]])
65+
; CHECK-NEXT: ret void
66+
;
67+
%interleave = tail call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %A, <vscale x 4 x i32> %B)
68+
%duplicate_by_interleave = tail call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %interleave, <vscale x 8 x i32> %interleave)
69+
store <vscale x 16 x i32> %duplicate_by_interleave, ptr %AB_duplicate, align 4
70+
ret void
71+
}

0 commit comments

Comments
 (0)