1 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3 %struct.C = type { ptr, i32 }
5 ; Check that we instcombine the load across the prefetch.
7 ; CHECK-LABEL: define signext i32 @foo
8 define signext i32 @foo(ptr %c) local_unnamed_addr #0 {
9 ; CHECK: store i32 %dec, ptr %length_
11 ; CHECK: llvm.prefetch
14 %0 = load ptr, ptr %c, align 8
15 %1 = load ptr, ptr %0, align 8
16 store ptr %1, ptr %c, align 8
17 %length_ = getelementptr inbounds %struct.C, ptr %c, i32 0, i32 1
18 %2 = load i32, ptr %length_, align 8
19 %dec = add nsw i32 %2, -1
20 store i32 %dec, ptr %length_, align 8
21 call void @llvm.prefetch(ptr %1, i32 0, i32 0, i32 1)
22 %3 = load i32, ptr %length_, align 8
26 ; Function Attrs: inaccessiblemem_or_argmemonly nounwind
27 declare void @llvm.prefetch(ptr nocapture readonly, i32, i32, i32)
29 attributes #0 = { noinline nounwind }
30 ; We've explicitly removed the function attrs from llvm.prefetch so we get the defaults.
31 ; attributes #1 = { inaccessiblemem_or_argmemonly nounwind }