1 ; RUN: opt -S -loop-rotate -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
3 ; CHECK-LABEL: @multiedge(
4 define void @multiedge() {
8 retry: ; preds = %sw.epilog, %entry
9 br i1 undef, label %cleanup, label %if.end
11 if.end: ; preds = %retry
12 switch i32 undef, label %sw.epilog [
13 i32 -3, label %cleanup
14 i32 -5, label %cleanup
15 i32 -16, label %cleanup
16 i32 -25, label %cleanup
19 sw.epilog: ; preds = %if.end
22 cleanup: ; preds = %if.end, %if.end, %if.end, %if.end, %retry
26 ; CHECK-LABEL: @read_line(
27 define internal fastcc i32 @read_line(i8* nocapture %f) unnamed_addr {
31 for.cond: ; preds = %if.end, %entry
32 %call = call i8* @prepbuffer(i8* nonnull undef)
33 %call1 = call i8* @fgets(i8* %call, i32 8192, i8* %f)
34 br i1 undef, label %if.then, label %if.end
36 if.then: ; preds = %for.cond
39 if.end: ; preds = %for.cond
40 %call4 = call i64 @strlen(i8* %call)
44 declare dso_local i8* @prepbuffer(i8*) local_unnamed_addr
45 declare dso_local i8* @fgets(i8*, i32, i8* nocapture) local_unnamed_addr
46 declare dso_local i64 @strlen(i8* nocapture) local_unnamed_addr
50 define dso_local fastcc void @loop3() unnamed_addr {
54 for.cond: ; preds = %for.body, %entry
55 br i1 undef, label %for.body, label %for.end81
57 for.body: ; preds = %for.cond
58 %.idx122.val = load i32, i32* undef, align 8
59 call fastcc void @cont()
62 for.end81: ; preds = %for.cond
67 define dso_local fastcc void @loop4() unnamed_addr {
71 while.cond: ; preds = %while.body, %entry
72 br i1 undef, label %while.end, label %while.body
74 while.body: ; preds = %while.cond
75 call fastcc void @cont()
78 while.end: ; preds = %while.cond
79 call fastcc void @cont()
80 call fastcc void @cont()
84 ; Function Attrs: inlinehint nounwind uwtable
85 declare dso_local fastcc void @cont() unnamed_addr
87 @glob_array = internal unnamed_addr constant [3 x i32] [i32 1, i32 0, i32 2], align 4
88 ; Test against failure in MemorySSAUpdater, when rotate clones instructions as Value.
90 define dso_local fastcc void @loop5() unnamed_addr {
94 do.cond: ; preds = %for.body
97 for.body: ; preds = %if.end, %entry
98 %indvar = phi i64 [ %indvar.next, %if.end ], [ 0, %entry ]
99 %array = getelementptr inbounds [3 x i32], [3 x i32]* @glob_array, i64 0, i64 %indvar
100 %0 = load i32, i32* %array, align 4
101 br i1 undef, label %do.cond, label %if.end
103 if.end: ; preds = %for.body
104 store i32 undef, i32* undef, align 4
105 %indvar.next = add nuw nsw i64 %indvar, 1