Skip to content

Commit 7fa8b62

Browse files
committed
[MemorySSA] Add pointer decrement loop clobber test case.
1 parent e6aa065 commit 7fa8b62

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

llvm/test/Analysis/MemorySSA/phi-translation.ll

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ cleanup: ; preds = %while.body, %while.
475475
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
476476
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
477477

478-
define void @another_loop_clobber() {
479-
; CHECK-LABEL: void @another_loop_clobber
478+
define void @another_loop_clobber_inc() {
479+
; CHECK-LABEL: void @another_loop_clobber_inc
480480
; CHECK-LABEL: loop.header:
481481
; CHECK-NEXT: ; 4 = MemoryPhi({entry,1},{cond.read,3})
482482

@@ -514,4 +514,43 @@ cleanup:
514514
ret void
515515
}
516516

517+
define void @another_loop_clobber_dec() {
518+
; CHECK-LABEL: void @another_loop_clobber_dec
519+
; CHECK-LABEL: loop.header:
520+
; CHECK-NEXT: ; 4 = MemoryPhi({entry,1},{cond.read,3})
521+
522+
; CHECK-LABEL: cond.read:
523+
; CHECK: ; MemoryUse(4)
524+
; CHECK-NEXT: %use = load i32, i32* %ptr.1, align 4
525+
; CHECK-NEXT: ; 2 = MemoryDef(4)
526+
; CHECK-NEXT: %c.2 = call i1 @cond(i32 %use)
527+
; CHECK-NEXT: %ptr.10 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i64 %sub
528+
; CHECK-NEXT: ; 3 = MemoryDef(2)
529+
; CHECK-NEXT: store i32 10, i32* %ptr.2, align 4
530+
531+
entry:
532+
%nodeStack = alloca [12 x i32], align 4
533+
%c.1 = call i1 @cond(i32 1)
534+
br i1 %c.1, label %cleanup, label %loop.header
535+
536+
loop.header: ; preds = %entry, %while.cond.backedge
537+
%depth.1 = phi i64 [ %sub, %cond.read], [ 20, %entry ]
538+
%cmp = icmp sgt i64 %depth.1, 6
539+
%sub = sub nsw nuw i64 %depth.1, 3
540+
%sub2 = sub nsw nuw i64 %depth.1, 6
541+
br i1 %cmp, label %cond.read, label %cleanup
542+
543+
cond.read: ; preds = %while.cond
544+
%ptr.1 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i64 %depth.1
545+
%ptr.2 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i64 %sub2
546+
%use = load i32, i32* %ptr.1, align 4
547+
%c.2 = call i1 @cond(i32 %use)
548+
%ptr.10 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i64 %sub
549+
store i32 10, i32* %ptr.2, align 4
550+
br i1 %c.2, label %loop.header, label %cleanup
551+
552+
cleanup:
553+
ret void
554+
}
555+
517556
declare i1 @cond(i32)

0 commit comments

Comments
 (0)