1 ; RUN: opt -S -loop-sink < %s | FileCheck %s
3 ; The load instruction should not be sunk into following loop.
6 ; CHECK-NEXT: %ptr = load i8*, i8** %pp, align 8
7 ; CHECK-NEXT: store i8* null, i8** %pp, align 8
9 define i32 @foo(i32 %n, i8** %pp) !prof !0 {
11 %ptr = load i8*, i8** %pp, align 8
12 store i8* null, i8** %pp, align 8
15 for.cond: ; preds = %for.body, %entry
16 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
17 %cmp = icmp ult i32 %i.0, %n
18 br i1 %cmp, label %for.body, label %for.end, !prof !1
20 for.body: ; preds = %for.cond
21 %0 = sext i32 %i.0 to i64
22 %arrayidx = getelementptr inbounds i8, i8* %ptr, i64 %0
23 %1 = load i8, i8* %arrayidx, align 1
24 %or19 = call i8 @llvm.bitreverse.i8(i8 %1)
25 %v = sext i8 %or19 to i32
26 %inc = add i32 %i.0, %v
29 for.end: ; preds = %for.cond
33 declare i8 @llvm.bitreverse.i8(i8) #0
34 attributes #0 = { nounwind readnone speculatable }
36 !0 = !{!"function_entry_count", i64 1}
37 !1 = !{!"branch_weights", i32 1, i32 2000}