1 ; RUN: opt -S -loop-sink < %s | FileCheck %s
2 ; RUN: opt -S -verify-memoryssa -enable-mssa-in-legacy-loop-sink -loop-sink < %s | FileCheck %s
3 ; RUN: opt -S -aa-pipeline=basic-aa -passes=loop-sink < %s | FileCheck %s
4 ; RUN: opt -S -verify-memoryssa -enable-mssa-in-loop-sink -aa-pipeline=basic-aa -passes=loop-sink < %s | FileCheck %s
6 ; The load instruction should not be sunk into following loop.
9 ; CHECK-NEXT: %ptr = load i8*, i8** %pp, align 8
10 ; CHECK-NEXT: store i8* null, i8** %pp, align 8
12 define i32 @foo(i32 %n, i8** %pp) !prof !0 {
14 %ptr = load i8*, i8** %pp, align 8
15 store i8* null, i8** %pp, align 8
18 for.cond: ; preds = %for.body, %entry
19 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
20 %cmp = icmp ult i32 %i.0, %n
21 br i1 %cmp, label %for.body, label %for.end, !prof !1
23 for.body: ; preds = %for.cond
24 %0 = sext i32 %i.0 to i64
25 %arrayidx = getelementptr inbounds i8, i8* %ptr, i64 %0
26 %1 = load i8, i8* %arrayidx, align 1
27 %or19 = call i8 @llvm.bitreverse.i8(i8 %1)
28 %v = sext i8 %or19 to i32
29 %inc = add i32 %i.0, %v
32 for.end: ; preds = %for.cond
36 declare i8 @llvm.bitreverse.i8(i8) #0
37 attributes #0 = { nounwind readnone speculatable }
39 !0 = !{!"function_entry_count", i64 1}
40 !1 = !{!"branch_weights", i32 1, i32 2000}