[MemorySSA] Add another loop clobber test case.
authorFlorian Hahn <flo@fhahn.com>
Wed, 16 Sep 2020 17:44:40 +0000 (18:44 +0100)
committerFlorian Hahn <flo@fhahn.com>
Thu, 17 Sep 2020 13:15:29 +0000 (14:15 +0100)
llvm/test/Analysis/MemorySSA/phi-translation.ll

index 7fa6e6c..5e065a2 100644 (file)
@@ -474,3 +474,45 @@ cleanup:                                          ; preds = %while.body, %while.
 
 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+define void @another_loop_clobber() {
+; CHECK-LABEL: void @another_loop_clobber
+; CHECK-LABEL: loop.header:
+; CHECK-NEXT:  ; 4 = MemoryPhi({entry,1},{cond.read,3})
+
+; CHECK-LABEL: cond.read:
+; NOLIMIT:     ; MemoryUse(liveOnEntry)
+; LIMIT:       ; MemoryUse(4)
+; CHECK-NEXT:  %use = load i32, i32* %ptr.1, align 4
+; CHECK-NEXT:  ; 2 = MemoryDef(4)
+; CHECK-NEXT:  %c.2 = call i1 @cond(i32 %use)
+; CHECK-NEXT:  %ptr.10 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i32 %inc
+; CHECK-NEXT:  ; 3 = MemoryDef(2)
+; CHECK-NEXT:  store i32 10, i32* %ptr.2, align 4
+
+entry:
+  %nodeStack = alloca [12 x i32], align 4
+  %c.1 = call i1 @cond(i32 1)
+  br i1 %c.1, label %cleanup, label %loop.header
+
+loop.header:                                       ; preds = %entry, %while.cond.backedge
+  %depth.1 = phi i32 [ %inc, %cond.read], [ 1, %entry ]
+  %cmp = icmp sgt i32 %depth.1, 0
+  %inc = add nsw i32 %depth.1, 3
+  %inc2 = add nsw i32 %depth.1, 6
+  br i1 %cmp, label %cond.read, label %cleanup
+
+cond.read:                                        ; preds = %while.cond
+  %ptr.1 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i32 %depth.1
+  %ptr.2 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i32 %inc2
+  %use = load i32, i32* %ptr.1, align 4
+  %c.2 = call i1 @cond(i32 %use)
+  %ptr.10 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, i32 %inc
+  store i32 10, i32* %ptr.2, align 4
+  br i1 %c.2, label %loop.header, label %cleanup
+
+cleanup:
+  ret void
+}
+
+declare i1 @cond(i32)