1; RUN: opt < %s -passes=instcombine -S | FileCheck %s 2 3%struct.C = type { ptr, i32 } 4 5; Check that we instcombine the load across the prefetch. 6 7; CHECK-LABEL: define signext i32 @foo 8define signext i32 @foo(ptr %c) local_unnamed_addr #0 { 9; CHECK: store i32 %dec, ptr %length_ 10; CHECK-NOT: load 11; CHECK: llvm.prefetch 12; CHECK-NEXT: ret 13entry: 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 23 ret i32 %3 24} 25 26; Function Attrs: inaccessiblemem_or_argmemonly nounwind 27declare void @llvm.prefetch(ptr nocapture readonly, i32, i32, i32) 28 29attributes #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 } 32