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