1 ; Test to make sure llvm.invariant.start calls are not treated as clobbers.
2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
5 declare ptr @llvm.invariant.start.p0(i64, ptr nocapture) nounwind readonly
6 declare void @llvm.invariant.end.p0(ptr, i64, ptr nocapture) nounwind
8 ; We forward store to the load across the invariant.start intrinsic
9 define i8 @forward_store() {
10 ; CHECK-LABEL: @forward_store
11 ; CHECK: call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
16 %i = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
21 declare i8 @dummy(ptr nocapture) nounwind readonly
23 ; We forward store to the load in the non-local analysis case,
24 ; i.e. invariant.start is in another basic block.
25 define i8 @forward_store_nonlocal(i1 %cond) {
26 ; CHECK-LABEL: forward_store_nonlocal
27 ; CHECK: call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
32 %i = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
33 br i1 %cond, label %loadblock, label %exit
40 %val = call i8 @dummy(ptr %a)
44 ; We should not value forward %foo to the invariant.end corresponding to %bar.
45 define i8 @forward_store1() {
46 ; CHECK-LABEL: forward_store1
47 ; CHECK: %foo = call ptr @llvm.invariant.start.p0
49 ; CHECK: %bar = call ptr @llvm.invariant.start.p0
50 ; CHECK: call void @llvm.invariant.end.p0(ptr %bar, i64 1, ptr %a)
54 %foo = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
56 %bar = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
57 call void @llvm.invariant.end.p0(ptr %bar, i64 1, ptr %a)